-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
PKG_NAME = nanocbor | ||
PKG_URL = https://github.com/bergzand/nanocbor | ||
PKG_VERSION = 44d9b1cfaa6829c5d1063f3c0e4a1733cfa409e3 | ||
PKG_LICENSE = LGPL-2.1 | ||
|
||
.PHONY: all | ||
|
||
all: git-download | ||
"$(MAKE)" -C $(PKG_BUILDDIR)/src \ | ||
-f $(RIOTPKG)/nanocbor/Makefile.$(PKG_NAME) | ||
|
||
include $(RIOTBASE)/pkg/pkg.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
INCLUDES += -I$(RIOTPKG)/nanocbor/include | ||
INCLUDES += -I$(PKGDIRBASE)/nanocbor/include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
MODULE = nanocbor | ||
|
||
SRC = decoder.c \ | ||
encoder.c | ||
|
||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* @defgroup pkg_nanocbor NanoCBOR library | ||
* @ingroup pkg | ||
* @ingroup sys | ||
* @brief CBOR encoder and decoder library for tiny devices | ||
* | ||
* This package contains the NanoCBOR library for a small CBOR encoder and | ||
* decoder. Flash footprint for encoding and decoding should be below 1K each. | ||
* | ||
* At the moment 8 bit and 16 bit MCU support is broken by upstream, see the | ||
* [issue](https://github.com/bergzand/NanoCBOR/issues/18). | ||
* | ||
* ## Usage | ||
* | ||
* Just add it as a package in your application: | ||
* | ||
* ```makefile | ||
* USEPKG += nanocbor | ||
* ``` | ||
* | ||
* @see https://github.com/bergzand/nanocbor | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (C) 2019 Koen Zandberg | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @defgroup nanocbor_config NanoCBOR configuration header | ||
* @brief Provides compile-time configuration for nanocbor | ||
*/ | ||
|
||
#ifndef NANOCBOR_CONFIG_H | ||
#define NANOCBOR_CONFIG_H | ||
|
||
#include <stdint.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#ifndef NANOCBOR_RECURSION_MAX | ||
#define NANOCBOR_RECURSION_MAX 10 | ||
#endif | ||
|
||
/** | ||
* @brief library providing htonll, be64toh or equivalent. Must also provide | ||
* the reverse operation (ntohll, htobe64 or equivalent) | ||
*/ | ||
#ifndef NANOCBOR_BYTEORDER_HEADER | ||
#define NANOCBOR_BYTEORDER_HEADER "byteorder.h" | ||
#endif | ||
|
||
/** | ||
* @brief call providing htonll or be64toh or equivalent functionality | ||
* | ||
* must take a uint64_t big endian and return it in host endianess | ||
*/ | ||
#ifndef NANOCBOR_BE64TOH_FUNC | ||
#define NANOCBOR_BE64TOH_FUNC(be) (ntohll(be)) | ||
#endif | ||
|
||
/** | ||
* @brief call providing htonll or htobe64 or equivalent functionality | ||
* | ||
* must take a uint64_t in host endianess and return the big endian value | ||
*/ | ||
#ifndef NANOCBOR_HTOBE64_FUNC | ||
#define NANOCBOR_HTOBE64_FUNC(be) (htonll(be)) | ||
#endif | ||
|
||
/** | ||
* @brief call providing htonll or htobe32 or equivalent functionality | ||
* | ||
* must take a uint32_t in host endianess and return the big endian value | ||
*/ | ||
#ifndef NANOCBOR_HTOBE32_FUNC | ||
#define NANOCBOR_HTOBE32_FUNC(he) htonl(he) | ||
#endif | ||
|
||
/** | ||
* @brief configuration for size_t SIZE_MAX equivalent | ||
*/ | ||
#ifndef NANOCBOR_SIZE_SIZET | ||
#if (SIZE_MAX == UINT16_MAX) | ||
#define NANOCBOR_SIZE_SIZET NANOCBOR_SIZE_SHORT | ||
#elif (SIZE_MAX == UINT32_MAX) | ||
#define NANOCBOR_SIZE_SIZET NANOCBOR_SIZE_WORD | ||
#elif (SIZE_MAX == UINT64_MAX) | ||
#define NANOCBOR_SIZE_SIZET NANOCBOR_SIZE_LONG | ||
#else | ||
#error ERROR: unable to determine maximum size of size_t | ||
#endif | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* NANOCBOR_CONFIG_H */ |