![]() |
ISSDK
1.8
IoT Sensing Software Development Kit
|
The data_format_json.c file implements JSON data format interfaces and services. More...
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#include "data_format_json.h"
Go to the source code of this file.
Typedefs | |
typedef enum _json_packet_state_ | json_packet_state_t |
Enumerations | |
enum | _json_packet_state_ { STATE_NONE, STATE_START_PACKET, STATE_PAYLOAD, STATE_END_PACKET } |
Functions | |
int32_t | JSON_Serialize (char *pStr, char *pDataTagStr, char *pDataValue, json_format_t type, bool end) |
The function to serialize the data,. More... | |
int32_t | JSON_Deserialize (void *pInData, void *pDataTag, char *pDataValue, json_format_t type) |
The function to deserialize the data,. More... | |
void | JSON_BlockDataRead_BlockingCall (host_interface_handle_t *pHandle, void *pRecvData) |
The function provides block data read for the JSON stream, This is for Blocking receive call. More... | |
int32_t | JSON_Get_Stream_NonBlockingCall (void *pRecvData, uint8_t data, uint8_t *state, uint8_t *buffIndex) |
This function is a helper function to get json stream where the data length is unknown. More... | |
bool | JSON_Process_Rx_Byte (uint8_t c, host_rx_packet_t *pHostRxPkt) |
Function to handle incomming JSON encoded bytes form the Host over UART. More... | |
size_t | JSON_Process_Tx_Msg (const uint8_t *pBuffer, uint8_t *pMsg, size_t size) |
Variables | |
const char * | gpJsonHeader = {"{\"d\":{"} |
const char * | gpJsonFooter = "}}" |
The data_format_json.c file implements JSON data format interfaces and services.
Definition in file data_format_json.c.
typedef enum _json_packet_state_ json_packet_state_t |
enum _json_packet_state_ |
Enumerator | |
---|---|
STATE_NONE | |
STATE_START_PACKET | |
STATE_PAYLOAD | |
STATE_END_PACKET |
Definition at line 28 of file data_format_json.c.
void JSON_BlockDataRead_BlockingCall | ( | host_interface_handle_t * | pHandle, |
void * | pRecvData | ||
) |
The function provides block data read for the JSON stream, This is for Blocking receive call.
This can be the argument to host interface
[in] | pHandle | - pointer to a formated data stream |
[out] | pRecvData | - Pointer to RecvBuffer; |
Definition at line 75 of file data_format_json.c.
References _host_interface_handle_::commHandle, data, _host_interface_handle_::pCommInterface, _comm_interface_::Receive, STATE_NONE, STATE_PAYLOAD, and STATE_START_PACKET.
int32_t JSON_Deserialize | ( | void * | pInData, |
void * | pDataTag, | ||
char * | pDataValue, | ||
json_format_t | type | ||
) |
The function to deserialize the data,.
it applys the deserialization in a single data element,
[in] | pStr | - pointer to a formated data stream |
[out] | pDataTagStr | - Data tag name for a data |
[out] | pDataValue | - Data value |
[in] | type | - Json data type |
Definition at line 69 of file data_format_json.c.
References DATA_FORMAT_JSON_OK.
int32_t JSON_Get_Stream_NonBlockingCall | ( | void * | pRecvData, |
uint8_t | data, | ||
uint8_t * | state, | ||
uint8_t * | buffIndex | ||
) |
This function is a helper function to get json stream where the data length is unknown.
Basically look for start and end packets and form a packet
[out] | pRecvData | - Pointer to RecvBuffer; |
[out] | data | - one byte of data received. [in] event - status event for send complete and receive complete |
Definition at line 117 of file data_format_json.c.
References DATA_FORMAT_JSON_OK, STATE_NONE, STATE_PAYLOAD, and STATE_START_PACKET.
bool JSON_Process_Rx_Byte | ( | uint8_t | c, |
host_rx_packet_t * | pHostRxPkt | ||
) |
Function to handle incomming JSON encoded bytes form the Host over UART.
This function will be called on receipt of every UART Byte and will do the JSON combination to create a Host Message.
[in] | uint8_t | c The character in the UART payload. |
[in] | host_rx_packet_t | *pHostRxPkt The Host Packet context structure. |
Definition at line 158 of file data_format_json.c.
Referenced by Host_IO_Receive().
size_t JSON_Process_Tx_Msg | ( | const uint8_t * | pBuffer, |
uint8_t * | pMsg, | ||
size_t | size | ||
) |
Definition at line 164 of file data_format_json.c.
Referenced by Host_IO_Send().
int32_t JSON_Serialize | ( | char * | pStr, |
char * | pDataTagStr, | ||
char * | pDataValue, | ||
json_format_t | type, | ||
bool | end | ||
) |
The function to serialize the data,.
it applys the serialization in single data element, Once user finishes the data stream with different data tag, set end flag to TRUE.
[in] | pStr | - pointer to the data stream - formated data put into this buffer |
[in] | pDataTagStr | - Data tag name for a data |
[in] | pDataValue | - Data value |
[in] | type | - Json data type |
[in] | end | - flag determine the end of data stream serialization. |
Definition at line 38 of file data_format_json.c.
References DATA_FORMAT_JSON_OK, gpJsonFooter, gpJsonHeader, and JSON_TYPE_OBJECT.
const char* gpJsonFooter = "}}" |
Definition at line 21 of file data_format_json.c.
Referenced by JSON_Serialize().
const char* gpJsonHeader = {"{\"d\":{"} |
Definition at line 20 of file data_format_json.c.
Referenced by JSON_Serialize().