1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

pkg: add cn-cbor CBOR implementation

This commit is contained in:
Kaspar Schleiser 2017-11-13 22:10:11 +01:00 committed by Lorenz Hüther
parent 74d3255fed
commit 70f0d844ac
7 changed files with 90 additions and 0 deletions

12
pkg/cn-cbor/Makefile Normal file
View File

@ -0,0 +1,12 @@
PKG_NAME=cn-cbor
PKG_URL=https://github.com/cabo/cn-cbor
PKG_VERSION=2f9c3b1931eb012909e74f3b628e6a31fd446ad1
PKG_LICENSE=MIT
.PHONY: all
all: git-download
@cp Makefile.cn-cbor $(PKG_BUILDDIR)/src/Makefile
"$(MAKE)" -C $(PKG_BUILDDIR)/src
include $(RIOTBASE)/pkg/pkg.mk

View File

@ -0,0 +1,3 @@
MODULE := cn-cbor
include $(RIOTBASE)/Makefile.base

View File

@ -0,0 +1 @@
INCLUDES += -I$(PKGDIRBASE)/cn-cbor/include

8
pkg/cn-cbor/doc.txt Normal file
View File

@ -0,0 +1,8 @@
/**
* @defgroup pkg_cn-cbor cn-cbor
* @ingroup pkg
* @ingroup sys
* @brief A constrained node implementation of CBOR in C
*
* @see https://github.com/cabo/cn-cbor
*/

View File

@ -0,0 +1,10 @@
APPLICATION = pkg_cn-cbor
include ../Makefile.tests_common
USEPKG += cn-cbor
USEMODULE += posix
include $(RIOTBASE)/Makefile.include
test:
tests/01-run.py

42
tests/pkg_cn-cbor/main.c Normal file
View File

@ -0,0 +1,42 @@
/*
* Copyright (C) 2017 Kaspar Schleiser <kaspar@schleiser.de>
*
* 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 tests
* @{
*
* @file
* @brief cn-cbor test application
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
*
* @}
*/
#include <stdio.h>
#include <string.h>
#include "cn-cbor/cn-cbor.h"
#define CBOR_TEST { 0x17 } /* 23 */
int main(void)
{
const char cbor[] = CBOR_TEST;
cn_cbor *c = cn_cbor_decode((const uint8_t *)cbor, strlen(cbor), NULL);
if (c && (c->v.sint == 23)) {
puts("[SUCCESS]");
}
else {
puts("[FAIL]");
}
return 0;
}

View File

@ -0,0 +1,14 @@
#!/usr/bin/env python3
import os
import sys
sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner'))
import testrunner
def testfunc(child):
child.expect('[SUCCESS]')
if __name__ == "__main__":
sys.exit(testrunner.run(testfunc))