elemy-sensortree 1.0.0
Macros | Functions
el_sensorsnode_json.c File Reference
#include "stdint.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <errno.h>
#include <unistd.h>
#include "elsensortree/el_sensorsnode_json.h"
#include "elutils/el_utils.h"
Include dependency graph for el_sensorsnode_json.c:

Macros

#define _GNU_SOURCE
 

Functions

int parse_node_fw_version (struct json_object *pobj, node_fw_version_t *p)
 parse json obj for node_fw_version_t More...
 
struct json_object * json_node_fw_version (node_fw_version_t *p)
 create and fill json object from node_fw_version_t More...
 
int parse_node_addr (struct json_object *pobj, node_addr_t *paddr)
 parse json obj for node_addr_t More...
 
struct json_object * json_node_addr (node_addr_t *addr, int as_string)
 create and fill json object from node_addr_t as object More...
 
int parse_serialnum (struct json_object *pobj, node_serial_num_t *sn)
 parse json obj for serialnum node_serial_num_t More...
 
struct json_object * json_serialnum (node_serial_num_t *sernum)
 create and fill json object from node_serial_num_t as object More...
 
int parse_node_info (struct json_object *pobj, node_info_t *p)
 parse json obj for node_info_t More...
 
struct json_object * json_node_info (node_info_t *p)
 create and fill json object from node_info_t as object More...
 
int parse_sensor_value (struct json_object *pobj, sensor_value_t *p)
 parse json obj for sensor_value_t More...
 
struct json_object * json_sensor_value (sensor_value_t *p)
 create and fill json object from sensor_value_t as object More...
 
int parse_node_status (struct json_object *pobj, node_status_t *p)
 
struct json_object * json_node_status (node_status_t *p)
 
int parse_sensors_node (struct json_object *pobj, sensors_node_t *p)
 
struct json_object * json_sensors_node (sensors_node_t *p)
 
void print_sensors_node (sensors_node_t *p, char *msg)
 
int parse_sensors_data (struct json_object *pobj, sensors_data_t **pp)
 parse json with sensors_data More...
 
struct json_object * json_sensors_data (sensors_data_t *p)
 
void print_sensors_data (sensors_data_t *p, char *msg)
 

Detailed Description

Created on: 25 мар. 2024 г. Author: ps

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Function Documentation

◆ json_node_addr()

struct json_object * json_node_addr ( node_addr_t addr,
int  as_string 
)

create and fill json object from node_addr_t as object

Parameters
addrnode_addr_t ptr of node address
as_stringif 0 - create json_object as {"a0":0....} else create json_object as string "0x1234"
Returns
ptr to addr object on success,
NULL on error
Here is the caller graph for this function:

◆ json_node_fw_version()

struct json_object * json_node_fw_version ( node_fw_version_t *  p)

create and fill json object from node_fw_version_t

Parameters
pobject of node_fw_version_t
Returns
ptr to object on success
NULL on error
Here is the caller graph for this function:

◆ json_node_info()

struct json_object * json_node_info ( node_info_t p)

create and fill json object from node_info_t as object

Parameters
sernumptr to node_info_t
Returns
ptr to object on success,
NULL on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ json_node_status()

struct json_object * json_node_status ( node_status_t *  p)
Here is the caller graph for this function:

◆ json_sensor_value()

struct json_object * json_sensor_value ( sensor_value_t *  p)

create and fill json object from sensor_value_t as object

Parameters
sernumptr to sensor_value_t
Returns
ptr to object on success,
NULL on error
Here is the caller graph for this function:

◆ json_sensors_data()

struct json_object * json_sensors_data ( sensors_data_t *  p)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ json_sensors_node()

struct json_object * json_sensors_node ( sensors_node_t *  p)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ json_serialnum()

struct json_object * json_serialnum ( node_serial_num_t *  sernum)

create and fill json object from node_serial_num_t as object

Parameters
addrnode_addr_t ptr of node address
as_stringif 1 create object as json_string
Returns
ptr to object on success,
NULL on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_node_addr()

int parse_node_addr ( struct json_object *  pobj,
node_addr_t paddr 
)

parse json obj for node_addr_t

Parameters
pobjptr to json obj
paddrptr to node_addr_t
Returns
0 success,
-1 error

on error rollback all mallocs

accept two variants in json:

  • "0x1234"
  • {"a0":1,"a1":2,"a2":3,"a3":4}
Here is the caller graph for this function:

◆ parse_node_fw_version()

int parse_node_fw_version ( struct json_object *  pobj,
node_fw_version_t *  p 
)

parse json obj for node_fw_version_t

Parameters
pobjptr to json obj
dsdptr to node_fw_version_t
Returns
0 success,
-1 error

on error rollback all mallocs

Here is the caller graph for this function:

◆ parse_node_info()

int parse_node_info ( struct json_object *  pobj,
node_info_t p 
)

parse json obj for node_info_t

Parameters
pobjptr to json obj
pptr to node_info_t
Returns
0 success,
-1 error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_node_status()

int parse_node_status ( struct json_object *  pobj,
node_status_t *  p 
)
Here is the caller graph for this function:

◆ parse_sensor_value()

int parse_sensor_value ( struct json_object *  pobj,
sensor_value_t *  p 
)

parse json obj for sensor_value_t

Parameters
pobjptr to json obj
pptr to sensor_value_t
Returns
0 success,
-1 error
Here is the caller graph for this function:

◆ parse_sensors_data()

int parse_sensors_data ( struct json_object *  pobj,
sensors_data_t **  pp 
)

parse json with sensors_data

Parameters
pobjobject of "sensor_data"
ppholder of pointer to sensors_data struct
Returns
- on success
-1 on error
1 in data rebuilded (parsed)

if (*pp == NULL) parsing is needed. NEW struct sensors_data_t is malloc into *pp if (*pp != NULL && **pp.crc == new_crc && **pp.data.updateCounter == new_updateCounter && **p.data.nodesСount == new_nodesСount) do nothing return 0; if (*pp != NULL && **p.data.nodesСount == new_nodesСount && (**pp.crc != new_crc || **pp.data.updateCounter || new_updateCounter) parse into existing struct sensors_data_t. return 1 if (*pp != NULL && **p.data.nodesСount != new_nodesСount) parse into new struct sensors_data_t

Here is the call graph for this function:

◆ parse_sensors_node()

int parse_sensors_node ( struct json_object *  pobj,
sensors_node_t *  p 
)
Here is the call graph for this function:

◆ parse_serialnum()

int parse_serialnum ( struct json_object *  pobj,
node_serial_num_t *  sn 
)

parse json obj for serialnum node_serial_num_t

Parameters
pobjptr to json obj
paddrptr to node_addr_t
Returns
0 success, -1 error

on error rollback all mallocs

Here is the call graph for this function:

◆ print_sensors_data()

void print_sensors_data ( sensors_data_t *  p,
char *  msg 
)
Here is the call graph for this function:

◆ print_sensors_node()

void print_sensors_node ( sensors_node_t *  p,
char *  msg 
)
Here is the call graph for this function: