src.dualinventive.com/dinet/sec-multi-proxy/libdi/include/di/rpc/structures.h

179 lines
4.9 KiB
C

/**
* @file include/di/rpc/structures.h
* @brief DI-Net RPC implementation specific data structures
* @copyright 2015 Dual Inventive Technology Centre B.V.
*/
#ifndef LIBDI_INCLUDE_DI_RPC_STRUCTURES_H_
#define LIBDI_INCLUDE_DI_RPC_STRUCTURES_H_
#include <di/types.h>
#include <di/device.h>
#include <di/array.h>
#include <di/rpc/types.h>
#include <di/constants/rpc/structures.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* RPC data value union
*/
union di_rpc_data_value {
bool b; /**< Boolean */
int8_t s8; /**< Signed 8-bit */
int16_t s16; /**< Signed 16-bit */
int32_t s32; /**< Signed 32-bit */
int64_t s64; /**< Signed 64-bit */
uint8_t u8; /**< Unsigned 8-bit */
uint16_t u16; /**< Unsigned 16-bit */
uint32_t u32; /**< Unsigned 32-bit */
uint64_t u64; /**< Unsigned 64-bit */
float f; /**< Single precision float */
double d; /**< Double precision float */
const char *s; /**< String (null terminated) */
};
struct di_rpc_data_values {
uint64_t interval; /**< interval between samples in array in nanoseconds */
uint16_t len;
uint16_t package_nr;
uint16_t nrof_packages;
float *pt_data; /**< pointer to data array */
};
/**
* RPC message (header)
*/
struct di_rpc_msg {
uint8_t dinetrpc; /**< dinetrpc version */
bool rt; /**< rpc realtime message flag */
uint16_t rt_seqnr; /**< realtime message sequence number */
enum di_rpc_msg_type msg_type; /**< message type (req, rep, pub) */
enum di_rpc_types type; /**< rpc type (encoded integer), e.g "device:info" */
char device_uid[DI_DEVICE_UID_LEN]; /**< device:uid */
di_project_id_t project_id; /**< project:id */
di_rpc_id_t id; /**< request/reply id */
di_errno_t err; /**< error code (e.g used when reply error) */
struct {
const uint8_t *buffer; /**< Start of MessagePack params map */
size_t size; /**< Size of params map in bytes */
} params;
};
/**
* RPC "<class>:info"
*/
struct di_rpc_info {
di_uid_t uid; /**< Unique ID */
enum di_rpc_data_type data_type; /**< Data type */
const char *label; /**< Label */
struct di_array enumerator; /**< Enumerator */
};
/**
* RPC "config:info"
*/
struct di_rpc_config_info {
di_uid_t uid; /**< Unique ID */
enum di_rpc_data_type data_type; /**< Data type */
const char *label; /**< Label */
struct di_array enumerator; /**< Enumerator */
enum di_rpc_data_field field; /**< Default value type */
union di_rpc_data_value value; /**< Default value */
};
/**
* RPC "device:info" version item
*/
struct di_rpc_device_info_version {
const char *key;
const char *value;
};
/**
* RPC "device:info"
*/
struct di_rpc_device_info {
const char *type; /**< Device type string, e.g "zkl-3000-rc" */
const struct di_rpc_device_info_version *version; /**< Device version property */
size_t versionn;
};
/**
* RPC "device:data"
*/
struct di_rpc_device_data {
bool error; /**< Device has one or more errors */
bool warning; /**< Device has one or more warnings */
di_errno_t *errors; /**< Device raised error list (may be NULL) */
size_t errorsn; /**< Device errors list size */
const char *state; /**< Device state string @see di_device_state */
};
/**
* RPC log:msg
*/
struct di_rpc_log {
const char *msg; /**< Human readable log message (without newline) */
};
/**
* RPC "<class>:data" structure, e.g used for "sensor:data"
*/
struct di_rpc_data {
di_uid_t uid; /**< Unique ID */
di_time_t time; /**< Timestamp of value (dinet timestamp) */
enum di_rpc_data_field field; /**< Value field selector */
union di_rpc_data_value value; /**< Value */
struct di_rpc_data_values values; /**< Values */
};
/**
* RPC gps sensor data structure
*/
struct di_rpc_sensor_data_gps {
di_time_t time; /**< Last good fix update (dinet timestamp) */
double latitude; /**< Latitude decimal notation */
double longitude; /**< Longitude decimal notation */
float hdop; /**< Horizontal dilution of precision */
};
/**
* RPC connection:info data structure for the cellular transport
*/
struct di_rpc_connection_info_transport_cellular {
const char *oper;
const char *imsi;
const char *iccid;
const char *imei;
const char *gprs_apn;
const char *endpoint;
};
/**
* RPC connection:info data structure for the can transport
*/
struct di_rpc_connection_info_transport_can {
uint32_t nodeid;
};
/**
* RPC connection:info data structure
*/
struct di_rpc_connection_info {
uint32_t timeout; /**< The timeout in seconds that this device is considered offline. */
const char **gateways;
size_t gatewaysn;
/**< The cellular transport layer of the connection (must be NULL when not used) */
const struct di_rpc_connection_info_transport_cellular *transport_cellular;
/**< The CAN transport layer of the connection (must be NULL when not used) */
const struct di_rpc_connection_info_transport_can *transport_can;
};
#ifdef __cplusplus
}
#endif
#endif /* LIBDI_INCLUDE_DI_RPC_STRUCTURES_H_ */