#include <senml_basepack.h>
|
| | SenMLBasePack () |
| |
| | ~SenMLBasePack () |
| |
| int | toJson (Stream &dest, SenMLStreamMethod format=SENML_RAW) |
| |
| int | toJson (char *dest, int length, SenMLStreamMethod format=SENML_RAW) |
| |
| int | toCbor (Stream &dest, SenMLStreamMethod format=SENML_RAW) |
| |
| int | toCbor (char *dest, int length, SenMLStreamMethod format=SENML_RAW) |
| |
| void | fromJson (Stream &source, SenMLStreamMethod format=SENML_RAW) |
| |
| void | fromJson (const char *source) |
| |
| void | fromCbor (Stream &source, SenMLStreamMethod format=SENML_RAW) |
| |
| void | fromCbor (char *source, int length, SenMLStreamMethod format) |
| |
| bool | add (SenMLBase &item) |
| |
| bool | clear () |
| |
| SenMLBase * | getFirst () |
| |
| virtual int | getCount () |
| |
| virtual int | fieldsToJson ()=0 |
| |
| virtual int | fieldsToCbor ()=0 |
| |
| virtual const char * | getBaseName () |
| |
| virtual SenMLUnit | getBaseUnit () |
| |
| | SenMLBase () |
| |
| | ~SenMLBase () |
| |
| SenMLBase * | getNext () |
| |
| SenMLBase * | getRoot () |
| |
| virtual void | adjustToBaseTime (double prev, double time) |
| |
| virtual int | fieldsToJson ()=0 |
| |
| virtual int | fieldsToCbor ()=0 |
| |
SenMLBasePack represents a single senml document that can be sent or received.
◆ SenMLBasePack()
| SenMLBasePack::SenMLBasePack |
( |
| ) |
|
|
inline |
◆ ~SenMLBasePack()
| SenMLBasePack::~SenMLBasePack |
( |
| ) |
|
|
inline |
◆ add()
Adds the specified SenML object to the document. The item will be appended to the end of the linked list. The item being added, can be a regular SenMLRecord or another SenMLPack object if you want to send data for multiple devices in 1 SenML message. Check the result of the function to see if the operation was successful or not. Possible reasons for failure:
- if the item being added is already part of a document.
- Parameters
-
| item | a pointer to a SenMlRecord or SenMLPack that needs to be added to the document. |
- Returns
- true upon success, otherwise false.
◆ clear()
| bool SenMLBasePack::clear |
( |
| ) |
|
Clear out the document and remove all the children. Children aren't destroyed, this is up to the developer.
- Returns
- true (at the moment, the function does not yet return false as it doesn't detect any errors)
◆ contentToCbor()
| int SenMLBasePack::contentToCbor |
( |
| ) |
|
|
protectedvirtual |
◆ contentToJson()
| int SenMLBasePack::contentToJson |
( |
| ) |
|
|
protectedvirtual |
◆ fieldsToCbor()
| virtual int SenMLBasePack::fieldsToCbor |
( |
| ) |
|
|
pure virtual |
renders all the fields to cbor format. renders all the fields of the object without the length info at the beginning note: this is public so that custom implementations for the record object can use other objects internally and render to json using this function (ex: coordinatesRecord using 3 floatRecrods for lat, lon & alt.
- Returns
- : The number of bytes that were written.
Implements SenMLBase.
Implemented in SenMLDoublePack, SenMLIntPack, SenMLPack, and SenMLSimplePack.
◆ fieldsToJson()
| virtual int SenMLBasePack::fieldsToJson |
( |
| ) |
|
|
pure virtual |
renders all the fields to json, without the starting and ending brackets. Inheriters can extend this function if they want to add extra fields to the json output note: this is public so that custom implementations for the record object can use other objects internally and render to json using this function (ex: coordinatesRecord using 3 floatRecrods for lat, lon & alt.
- Returns
- : None
Implements SenMLBase.
Implemented in SenMLDoublePack, SenMLIntPack, SenMLPack, and SenMLSimplePack.
◆ fromCbor() [1/2]
parse senml cbor from the specified memory and, for each registered actuator, call the appropriate event on the actuator itself, for others, the callback function PACK_ACTUATOR_SIGNATURE will be called, if present. This method takes a memory blob as input. The data must be fully defined.
- Parameters
-
| source | the source data to use as input. |
| length | the length of the source data. |
| format | determins how the data will be read (ex: as normal binary or in HEX format). See SenMLStreamMethod for possible methods. |
- Returns
- none
◆ fromCbor() [2/2]
read and parse senml cbor from the specified source and, for each registered actuator, call the appropriate event on the actuator itself, for others, the callback function PACK_ACTUATOR_SIGNATURE will be called, if present. This method is ideal for devices with very littel ram memory. It will block on most decices if there is no more input to be read from the stream and the end of the cbor structure is not yet reached. Note: on mbed systems, the blocking nature is not garanteed. Instead, if no more data is available before the end is reached, parsing will fail.
- Parameters
-
| source | the source stream to read the data from. |
| format | determins how the data will be read (ex: as normal binary or in HEX format). See SenMLStreamMethod for possible methods. |
- Returns
- none
◆ fromJson() [1/2]
| void SenMLBasePack::fromJson |
( |
const char * |
source | ) |
|
parse a senml json string from the specified source and, for each registered actuator, call the appropriate event on the actuator itself, for others, the callback function PACK_ACTUATOR_SIGNATURE will be called, if present. This method takes a string stored in memory as input. The json must be fully defined. It is up to the caller to transform it to a regular text string, if needed (ex: lora devices might send it in hex format).
- Parameters
-
| source | the source string to use as input. This must be null terminated. |
- Returns
- none
◆ fromJson() [2/2]
read and parse a senml json string from the specified source and, for each registered actuator, call the appropriate event on the actuator itself, for others, the callback function PACK_ACTUATOR_SIGNATURE will be called, if present. This method is ideal for devices with very littel ram memory. It will block on most devices if there is no more input to be read from the stream and the end of the json structure is not yet reached. Note: on mbed systems, the blocking nature is not garanteed. Instead, if no more data is available before the end is reached, parsing will fail.
- Parameters
-
| source | the source stream to read the data from. |
| format | determins how the data will be read (ex: as normal text or in HEX format). See SenMLStreamMethod for possible methods. |
- Returns
- none
◆ getArrayLength()
| int SenMLBasePack::getArrayLength |
( |
| ) |
|
|
protectedvirtual |
◆ getBaseName()
| virtual const char * SenMLBasePack::getBaseName |
( |
| ) |
|
|
inlinevirtual |
◆ getBaseUnit()
| virtual SenMLUnit SenMLBasePack::getBaseUnit |
( |
| ) |
|
|
inlinevirtual |
◆ getCount()
| int SenMLBasePack::getCount |
( |
| ) |
|
|
virtual |
- Returns
- the number of items this pack contains.
◆ getFieldLength()
| virtual int SenMLBasePack::getFieldLength |
( |
| ) |
|
|
inlineprotectedvirtual |
◆ getFirst()
get the first recrod of in this pack element.
- Returns
- null when this object is empty (has no children), otherwise, the first item (SenMLRecord or SenMLPack) of the list.
◆ isActuator()
| virtual bool SenMLBasePack::isActuator |
( |
| ) |
|
|
inlineprotectedvirtual |
◆ isPack()
| virtual bool SenMLBasePack::isPack |
( |
| ) |
|
|
inlineprotectedvirtual |
◆ setLast()
| void SenMLBasePack::setLast |
( |
SenMLBase & |
value | ) |
|
|
protected |
◆ setupStreamCtx() [1/2]
| void SenMLBasePack::setupStreamCtx |
( |
char * |
dest, |
|
|
int |
length, |
|
|
SenMLStreamMethod |
format |
|
) |
| |
|
protectedvirtual |
◆ setupStreamCtx() [2/2]
◆ toCbor() [1/2]
render the content of the current object to cbor data (binary). This function renders the data to a memory buffer. If the buffer is full before the entire object is rendered, an error will be written to the debug stream.
- Parameters
-
| dest | a memory buffer to which the data will be rendred. |
| length | the length of the memory buffer. |
| format | determins how the data will be rendered. See SenMLStreamMethod for possible methods. |
- Returns
- nr of bytes that were rendered
◆ toCbor() [2/2]
render the content of the current object to cbor data (binary). This function is ideal for devices with low memory usage but offers less control over the rendering process.
- Parameters
-
| dest | the destination stream to where the data will be rendered without buffering it in memory |
| format | determins how the data will be rendered. See SenMLStreamMethod for possible methods. |
- Returns
- nr of bytes that were rendered
◆ toJson() [1/2]
render the content of the current object to json data (string). This function renders the data to a memory buffer. If the buffer is full before the entire object is rendered, an error will be written to the debug stream.
- Parameters
-
| dest | a memory buffer to which the data will be rendred. |
| length | the length of the memory buffer. |
| format | determins how the data will be rendered. See SenMLStreamMethod for possible methods. |
- Returns
- nr of bytes that were rendered
◆ toJson() [2/2]
render the content of the current object to json data (string). This function is ideal for devices with low memory usage but offers less control over the rendering process.
- Parameters
-
| dest | the destination stream to where the data will be rendered without buffering it in memory |
| format | determins how the data will be rendered. See SenMLStreamMethod for possible methods. |
- Returns
- nr of bytes that were rendered
◆ SenMLBase
◆ SenMLCborParser
◆ SenMLJsonListener
◆ SenMLPack
The documentation for this class was generated from the following files: