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:
parent
74d3255fed
commit
70f0d844ac
12
pkg/cn-cbor/Makefile
Normal file
12
pkg/cn-cbor/Makefile
Normal 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
|
3
pkg/cn-cbor/Makefile.cn-cbor
Normal file
3
pkg/cn-cbor/Makefile.cn-cbor
Normal file
@ -0,0 +1,3 @@
|
||||
MODULE := cn-cbor
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
1
pkg/cn-cbor/Makefile.include
Normal file
1
pkg/cn-cbor/Makefile.include
Normal file
@ -0,0 +1 @@
|
||||
INCLUDES += -I$(PKGDIRBASE)/cn-cbor/include
|
8
pkg/cn-cbor/doc.txt
Normal file
8
pkg/cn-cbor/doc.txt
Normal 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
|
||||
*/
|
10
tests/pkg_cn-cbor/Makefile
Normal file
10
tests/pkg_cn-cbor/Makefile
Normal 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
42
tests/pkg_cn-cbor/main.c
Normal 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;
|
||||
}
|
14
tests/pkg_cn-cbor/tests/01-run.py
Executable file
14
tests/pkg_cn-cbor/tests/01-run.py
Executable 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))
|
Loading…
Reference in New Issue
Block a user