Golioth Firmware SDK
Loading...
Searching...
No Matches
golioth_payload_utils

Functions

int32_t golioth_payload_as_int (const uint8_t *payload, size_t payload_size)
 
float golioth_payload_as_float (const uint8_t *payload, size_t payload_size)
 
bool golioth_payload_as_bool (const uint8_t *payload, size_t payload_size)
 
bool golioth_payload_is_null (const uint8_t *payload, size_t payload_size)
 

Detailed Description

Functions for converting JSON types into C types

Function Documentation

◆ golioth_payload_as_bool()

bool golioth_payload_as_bool ( const uint8_t * payload,
size_t payload_size )

Convert raw byte payload into a bool

Parameters
payloadPointer to payload data
payload_sizeSize of payload, in bytes
Return values
truepayload is exactly the string "true"
falseotherwise

◆ golioth_payload_as_float()

float golioth_payload_as_float ( const uint8_t * payload,
size_t payload_size )

Convert raw byte payload into a float

Parameters
payloadPointer to payload data
payload_sizeSize of payload, in bytes
Returns
float value returned from strtof(payload, NULL)

◆ golioth_payload_as_int()

int32_t golioth_payload_as_int ( const uint8_t * payload,
size_t payload_size )

Convert raw byte payload into an int32_t

Parameters
payloadPointer to payload data
payload_sizeSize of payload, in bytes
Returns
int32_t value returned from strtol(payload, NULL, 10)

◆ golioth_payload_is_null()

bool golioth_payload_is_null ( const uint8_t * payload,
size_t payload_size )

Returns true if payload has no contents

Parameters
payloadPointer to payload data
payload_sizeSize of payload, in bytes
Return values
truepayload is NULL, payload_size is 0 or payload is exactly the string "null"
falseotherwise