KPN Things Device SDK
senml_helpers.h File Reference
#include "defaults.h"
#include "senml_enums.h"
#include <math.h>

Go to the source code of this file.

Data Structures

union  BaseData_t
 
struct  SenmlMemoryData_t
 
union  SenmlData_t
 
struct  StreamContext_t
 

Macros

#define SENML_MAX_DOUBLE_PRECISION   8
 
#define F(str)   str
 

Typedefs

typedef union BaseData_t BaseData
 
typedef struct SenmlMemoryData_t SenmlMemoryData
 
typedef union SenmlData_t SenmlData
 
typedef struct StreamContext_t StreamContext
 

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 *value, int length)
 
bool canPrint (int length)
 
int readChar ()
 
int peekChar ()
 
void flush ()
 
void readChars (unsigned char *buffer, int len)
 
bool charAvailable ()
 

Variables

StreamContext_streamCtx
 

Macro Definition Documentation

◆ F

#define F (   str)    str

◆ SENML_MAX_DOUBLE_PRECISION

#define SENML_MAX_DOUBLE_PRECISION   8

Typedef Documentation

◆ BaseData

typedef union BaseData_t BaseData

Internal helper struct that stores the base value to be used during rendering

◆ SenmlData

typedef union SenmlData_t SenmlData

Internal helper struct that stores information needed during the rendering process

◆ SenmlMemoryData

Internal helper struct that stores information needed during the rendering process

◆ StreamContext

Internal helper struct that stores information needed during the rendering process

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

◆ charAvailable()

bool charAvailable ( )
inline

Helper function for the parsing process Checks if there is data available on the stream. Warning: THIS CAN BE PROBLEMATIC ON MBED SYSTEMS>

◆ 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

◆ readChars()

void readChars ( unsigned char *  buffer,
int  len 
)
inline

Helper function for the parsing process Reads the specified nr of characters from the stream (_streamCtx) takes into account that the stream might contain hex values

Parameters
bufferthe buffer to store the values in.
lenthe nr of characters to read from the stream into the buffer. If the input contains hex values, the actual nr of characters read from the stream is double this value.

Variable Documentation

◆ _streamCtx

StreamContext* _streamCtx
extern

Internal data field used for the rendering process.