KPN Things Device SDK
senml_helpers.cpp File Reference
#include "senml_helpers.h"
#include <string.h>

Functions

int printByte (uint8_t value)
 
int printInt (int i)
 
int printDouble (double f, unsigned int digits)
 
int printBinaryAsBase64 (const unsigned char *data, unsigned int length)
 
int printUnit (SenMLUnit unit)
 
int printText (const char *const value, int length)
 
bool canPrint (int length)
 
int readChar ()
 
int peekChar ()
 
void flush ()
 

Variables

StreamContext_streamCtx = NULL
 

Function Documentation

◆ canPrint()

bool canPrint ( int  length)

Helper function for the generation process Determines if the underlying stream has enough space to write length bytes (_streamCtx).

always returns true for non buffer backed streams

◆ flush()

void flush ( )

Helper function for the parsing process flush and reset all input for the current data stream.

◆ peekChar()

int peekChar ( )

Helper function for the parsing process peek a character from the current data stream. takes into account that the stream might contain hex values.

◆ printBinaryAsBase64()

int printBinaryAsBase64 ( const unsigned char *  data,
unsigned int  length 
)

Helper function for the generation process convert the data array to base64 string and write to stream (_streamCtx)

Parameters
datapointer to the binary data blob that needs to be rendered as base64 to the stream.
lengththe length of the data blob

◆ printByte()

int printByte ( uint8_t  value)

Helper function for the generation process write a uint8_t as byte to the stream (_streamCtx).

Parameters
valuethe value to print

◆ printDouble()

int printDouble ( double  f,
unsigned int  digits 
)

Helper function for the generation process write a double as string to the stream (_streamCtx).

Parameters
fthe value to print
digitsthe nr of digits that should be printed after the comma.

◆ printInt()

int printInt ( int  i)

Helper function for the generation process write a int as string to the stream (_streamCtx).

Parameters
ithe value to print

◆ printText()

int printText ( const char *  value,
int  length 
)

Helper function for the generation process Writes the specified text to the stream (_streamCtx).

Parameters
valuethe value to write
lenthe length of the value.

◆ printUnit()

int printUnit ( SenMLUnit  unit)

Helper function for the generation process convert the unit to string and write to stream (_streamCtx).

Parameters
unitthe value to write as text to the stream.

◆ readChar()

int readChar ( )

Helper function for the parsing process read a character from the current data stream (_streamCtx) takes into account that the stream might contain hex values

Variable Documentation

◆ _streamCtx

StreamContext* _streamCtx = NULL

Internal data field used for the rendering process.