This is a library for processing CBOR RFC 7049 data.
Notable features of this library:
- Handles and identifies well-formed and not-well-formed CBOR data.
- Provides utility functions to make it easier to parse data.
- Provides some Stream and Print implementations to make it easy to interface with byte arrays and the EEPROM.
The classes you'll need are in the qindesign::cbor
namespace:
Reader
and Writer
. A complete example of how to use them are in
StructInBytes
.
The main class documentation can be found in src/CBOR.h
. Other documentation
can be found as follows:
- Utility functions:
src/CBOR_utils.h
Stream
andPrint
implementations:src/CBOR_streams.h
- Parsing helpers:
src/CBOR_parsing.h
Not all the files in this project are necessary in an installed library. Only the following files and directories need to be there:
examples/
library.properties
LICENSE
README.md
src/CBOR*
There are tests included in this project that rely on a project called ArduinoUnit. This should work out of the box on a Teensy, but some modifications may need to be made for ESP8266-based devices.
Note that the code for ArduinoUnit is not included in this library and needs to be downloaded separately.
In ArduinoUnit's source, change ArduinoUnitUtility/Compare.h
so that the
#if defined(F)
block at the top is changed to:
#if defined(F)
#ifdef ESP8266
#define typeof(x) __typeof__(x)
#undef PROGMEM
#define PROGMEM
#undef PGM_P
#define PGM_P const char *
#undef PGM_VOID_P
#define PGM_VOID_P const void *
#undef PSTR
#define PSTR(s) (s)
#undef pgm_read_byte
#define pgm_read_byte(addr) (*reinterpret_cast<const uint8_t*>(addr))
#undef pgm_read_word
#define pgm_read_word(addr) (*reinterpret_cast<const uint16_t*>(addr))
#else
#include <avr/pgmspace.h>
#endif // ESP8266
#endif
Code style for this project follows the Google C++ Style Guide.
- Concise Binary Object Representation (CBOR): RFC 7049
Copyright (c) 2017 Shawn Silverman