elemy-sensortree 1.0.0
|
#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"
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) |
Created on: 25 мар. 2024 г. Author: ps
#define _GNU_SOURCE |
struct json_object * json_node_addr | ( | node_addr_t * | addr, |
int | as_string | ||
) |
create and fill json object from node_addr_t as object
addr | node_addr_t ptr of node address |
as_string | if 0 - create json_object as {"a0":0....} else create json_object as string "0x1234" |
struct json_object * json_node_fw_version | ( | node_fw_version_t * | p | ) |
create and fill json object from node_fw_version_t
p | object of node_fw_version_t |
struct json_object * json_node_info | ( | node_info_t * | p | ) |
create and fill json object from node_info_t as object
sernum | ptr to node_info_t |
struct json_object * json_node_status | ( | node_status_t * | p | ) |
struct json_object * json_sensor_value | ( | sensor_value_t * | p | ) |
create and fill json object from sensor_value_t as object
sernum | ptr to sensor_value_t |
struct json_object * json_sensors_data | ( | sensors_data_t * | p | ) |
struct json_object * json_sensors_node | ( | sensors_node_t * | p | ) |
struct json_object * json_serialnum | ( | node_serial_num_t * | sernum | ) |
create and fill json object from node_serial_num_t as object
addr | node_addr_t ptr of node address |
as_string | if 1 create object as json_string |
int parse_node_addr | ( | struct json_object * | pobj, |
node_addr_t * | paddr | ||
) |
parse json obj for node_addr_t
pobj | ptr to json obj |
paddr | ptr to node_addr_t |
on error rollback all mallocs
accept two variants in json:
int parse_node_fw_version | ( | struct json_object * | pobj, |
node_fw_version_t * | p | ||
) |
parse json obj for node_fw_version_t
pobj | ptr to json obj |
dsd | ptr to node_fw_version_t |
on error rollback all mallocs
int parse_node_info | ( | struct json_object * | pobj, |
node_info_t * | p | ||
) |
parse json obj for node_info_t
pobj | ptr to json obj |
p | ptr to node_info_t |
int parse_node_status | ( | struct json_object * | pobj, |
node_status_t * | p | ||
) |
int parse_sensor_value | ( | struct json_object * | pobj, |
sensor_value_t * | p | ||
) |
parse json obj for sensor_value_t
pobj | ptr to json obj |
p | ptr to sensor_value_t |
int parse_sensors_data | ( | struct json_object * | pobj, |
sensors_data_t ** | pp | ||
) |
parse json with sensors_data
pobj | object of "sensor_data" |
pp | holder of pointer to sensors_data struct |
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
int parse_sensors_node | ( | struct json_object * | pobj, |
sensors_node_t * | p | ||
) |
int parse_serialnum | ( | struct json_object * | pobj, |
node_serial_num_t * | sn | ||
) |
parse json obj for serialnum node_serial_num_t
pobj | ptr to json obj |
paddr | ptr to node_addr_t |
on error rollback all mallocs
void print_sensors_data | ( | sensors_data_t * | p, |
char * | msg | ||
) |
void print_sensors_node | ( | sensors_node_t * | p, |
char * | msg | ||
) |