ISSDK  1.7
IoT Sensing Software Development Kit
Macros | Typedefs | Enumerations | Functions
data_format_json.h File Reference

The format_json.h file describes the structures and definitions for the data-format standard JSON. More...

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "host_interface_service.h"
#include "host_io_uart.h"
Include dependency graph for data_format_json.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define HOST_INTERFACE   1
 
#define DATA_FORMAT_JSON_OK   0
 

Typedefs

typedef enum _json_format_ json_format_t
 

Enumerations

enum  _json_format_ { JSON_TYPE_OBJECT, JSON_TYPE_ARRAY }
 

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)
 

Detailed Description

The format_json.h file describes the structures and definitions for the data-format standard JSON.

Definition in file data_format_json.h.

Macro Definition Documentation

◆ DATA_FORMAT_JSON_OK

#define DATA_FORMAT_JSON_OK   0

◆ HOST_INTERFACE

#define HOST_INTERFACE   1

Definition at line 44 of file data_format_json.h.

Typedef Documentation

◆ json_format_t

Enumeration Type Documentation

◆ _json_format_

Enumerator
JSON_TYPE_OBJECT 
JSON_TYPE_ARRAY 

Definition at line 54 of file data_format_json.h.

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 101 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 95 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 143 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 184 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 190 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 64 of file data_format_json.c.

References DATA_FORMAT_JSON_OK, gpJsonFooter, gpJsonHeader, and JSON_TYPE_OBJECT.