Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/cayenne-lpp: add support for Cayenne LPP format #8809

Merged
merged 2 commits into from
Mar 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pkg/cayenne-lpp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
PKG_NAME=cayenne-lpp
PKG_URL=https://github.com/aabadie/cayenne-lpp
PKG_VERSION=ad3aa26043e221eda28ac3da2484e1ef84986442
PKG_LICENSE=LGPLv2.1

.PHONY: all

all: git-download
"$(MAKE)" -C $(PKG_BUILDDIR) -f $(CURDIR)/Makefile.$(PKG_NAME)

include $(RIOTBASE)/pkg/pkg.mk
3 changes: 3 additions & 0 deletions pkg/cayenne-lpp/Makefile.cayenne-lpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MODULE = cayenne-lpp

include $(RIOTBASE)/Makefile.base
1 change: 1 addition & 0 deletions pkg/cayenne-lpp/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INCLUDES += -I$(PKGDIRBASE)/cayenne-lpp
14 changes: 14 additions & 0 deletions pkg/cayenne-lpp/doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @defgroup pkg_cayenne-lpp Cayenne Low Power Payload (LPP)
* @ingroup pkg
* @ingroup sys
* @brief Provides a RIOT support for Cayenne LPP format
*
* The Cayenne Low Power Payload (LPP) provides a convenient and easy way to
* send data over LPWAN networks such as LoRaWAN.
*
* For more details on the format, see
* https://mydevices.com/cayenne/docs_stage/lora/#lora-cayenne-low-power-payload
*
* @see https://github.com/aabadie/cayenne-lpp
*/
8 changes: 8 additions & 0 deletions tests/pkg_cayenne-lpp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
include ../Makefile.tests_common

USEPKG += cayenne-lpp

include $(RIOTBASE)/Makefile.include

test:
tests/01-run.py
17 changes: 17 additions & 0 deletions tests/pkg_cayenne-lpp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Cayenne LPP test
================

Usage
-----

Simply run the application on native using:

make all term

Expected result
---------------

The application should display the following output:

Cayenne LPP test application
03670110056700FF
59 changes: 59 additions & 0 deletions tests/pkg_cayenne-lpp/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (C) 2018 Inria
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup test
* @{
*
* @file
* @brief Cayenne Low Power Payload example application
*
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
*
* @}
*/

#include <stdio.h>

#include "cayenne_lpp.h"

static cayenne_lpp_t lpp;

static void _print_buffer(cayenne_lpp_t *lpp)
{
for (uint8_t i = 0; i < lpp->cursor; ++i) {
printf("%02X", lpp->buffer[i]);
}
puts("");
}

int main(void)
{
puts("Cayenne LPP test application");

/* generate payload like the one given as example at
* https://mydevices.com/cayenne/docs_stage/lora/#lora-cayenne-low-power-payload
*/
/* Device with 2 temperature sensors */
cayenne_lpp_add_temperature(&lpp, 3, 27.2);
cayenne_lpp_add_temperature(&lpp, 5, 25.5);
_print_buffer(&lpp);

/* Device with temperature and acceleration sensors */
cayenne_lpp_reset(&lpp);
cayenne_lpp_add_temperature(&lpp, 1, -4.1);
cayenne_lpp_add_accelerometer(&lpp, 6, 1.234, -1.234, 0);
_print_buffer(&lpp);

/* Device with GPS */
cayenne_lpp_reset(&lpp);
cayenne_lpp_add_gps(&lpp, 1, 42.3519, -87.9094, 10);
_print_buffer(&lpp);

return 0;
}
16 changes: 16 additions & 0 deletions tests/pkg_cayenne-lpp/tests/01-run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python3

import os
import sys


def testfunc(child):
child.expect_exact('03670110056700FF')
child.expect_exact('0167FFD8067104D1FB2F0000')
child.expect_exact('018806765EF2960A0003E8')


if __name__ == "__main__":
sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner'))
from testrunner import run
sys.exit(run(testfunc))