ISSDK  1.8
IoT Sensing Software Development Kit
Typedefs | Enumerations | Functions | Variables
data_format_json.c File Reference

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"
Include dependency graph for data_format_json.c:

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 = "}}"
 

Detailed Description

The data_format_json.c file implements JSON data format interfaces and services.

Definition in file data_format_json.c.

Typedef Documentation

◆ json_packet_state_t

Enumeration Type Documentation

◆ _json_packet_state_

Enumerator
STATE_NONE 
STATE_START_PACKET 
STATE_PAYLOAD 
STATE_END_PACKET 

Definition at line 28 of file data_format_json.c.

Function Documentation

◆ JSON_BlockDataRead_BlockingCall()

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

Parameters
[in]pHandle- pointer to a formated data stream
[out]pRecvData- Pointer to RecvBuffer;
Returns
None.
Constraints:
None
Reentrant: Yes

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.

◆ JSON_Deserialize()

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,

Parameters
[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
Returns
JSON_Deserialize() returns the status .
Constraints:
None
Reentrant: Yes

Definition at line 69 of file data_format_json.c.

References DATA_FORMAT_JSON_OK.

◆ JSON_Get_Stream_NonBlockingCall()

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

Parameters
[out]pRecvData- Pointer to RecvBuffer;
[out]data- one byte of data received. [in] event - status event for send complete and receive complete
Returns
DATA_FORMAT_JSON_OK, if data read is completed. else still get more data.
Constraints:
None
Reentrant: Yes

Definition at line 117 of file data_format_json.c.

References DATA_FORMAT_JSON_OK, STATE_NONE, STATE_PAYLOAD, and STATE_START_PACKET.

◆ JSON_Process_Rx_Byte()

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.

Parameters
[in]uint8_tc The character in the UART payload.
[in]host_rx_packet_t*pHostRxPkt The Host Packet context structure.
Returns
bool Success/Failure.
Constraints:
This should be the called only after DEBUG/UART has been initialized. No

Definition at line 158 of file data_format_json.c.

Referenced by Host_IO_Receive().

Here is the caller graph for this function:

◆ JSON_Process_Tx_Msg()

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().

Here is the caller graph for this function:

◆ JSON_Serialize()

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.

Parameters
[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.
Returns
JSON_Serialize() returns the status .
Constraints:
None
Reentrant: Yes

Definition at line 38 of file data_format_json.c.

References DATA_FORMAT_JSON_OK, gpJsonFooter, gpJsonHeader, and JSON_TYPE_OBJECT.

Variable Documentation

◆ gpJsonFooter

const char* gpJsonFooter = "}}"

Definition at line 21 of file data_format_json.c.

Referenced by JSON_Serialize().

◆ gpJsonHeader

const char* gpJsonHeader = {"{\"d\":{"}

Definition at line 20 of file data_format_json.c.

Referenced by JSON_Serialize().