142 lines
2.9 KiB
C
142 lines
2.9 KiB
C
/**
|
|
* @file include/di/rpc/structures.h
|
|
* @brief brief
|
|
* @date Aug 25, 2015
|
|
* @author jjacobs
|
|
* @copyright 2015 Dual Inventive Technology Centre B.V.
|
|
*
|
|
* descr
|
|
*/
|
|
#ifndef INCLUDE_DI_RPC_STRUCTURES_H_
|
|
#define INCLUDE_DI_RPC_STRUCTURES_H_
|
|
|
|
#include <di/types.h>
|
|
#include <di/device.h>
|
|
#include <di/array.h>
|
|
#include <di/rpc/types.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define DI_RPC_INVALID_UID 0U /**< Invalid class (sensor, notify etc) unique id for all rpc messages */
|
|
|
|
struct di_rpc_error {
|
|
di_errno_t code; /**< Error code */
|
|
uint64_t first; /**< DI-Net time of first occurrence */
|
|
uint64_t last; /**< DI-Net time of last occurrence */
|
|
uint32_t count; /**< Error counter */
|
|
};
|
|
|
|
/**
|
|
* Enumerator item
|
|
*/
|
|
struct di_rpc_enum {
|
|
const char *name; /** Name */
|
|
int32_t value; /** Value */
|
|
};
|
|
|
|
/**
|
|
*
|
|
*/
|
|
union di_rpc_data_value {
|
|
bool b;
|
|
int8_t s8;
|
|
int16_t s16;
|
|
int32_t s32;
|
|
int64_t s64;
|
|
uint8_t u8;
|
|
uint16_t u16;
|
|
uint32_t u32;
|
|
uint64_t u64;
|
|
float f;
|
|
double d;
|
|
const char *s;
|
|
};
|
|
|
|
/**
|
|
* RPC message (header)
|
|
*/
|
|
struct di_rpc_msg {
|
|
uint8_t dinetrpc;
|
|
enum di_rpc_msg_type msg_type;
|
|
enum di_rpc_types type;
|
|
char device_uid[DI_DEVICE_UID_LEN];
|
|
uint32_t id;
|
|
di_errno_t err;
|
|
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 {
|
|
uint16_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 {
|
|
uint16_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 */
|
|
};
|
|
|
|
struct di_rpc_device_info {
|
|
const char *type;
|
|
uint8_t revision;
|
|
const char *version;
|
|
};
|
|
|
|
struct di_rpc_device_data {
|
|
bool error;
|
|
const char *state;
|
|
};
|
|
|
|
/**
|
|
* RPC log:msg
|
|
*/
|
|
struct di_rpc_log {
|
|
const char *msg;
|
|
};
|
|
|
|
/**
|
|
* RPC "<class>:data"
|
|
*/
|
|
struct di_rpc_data {
|
|
uint16_t uid;
|
|
uint64_t time;
|
|
enum di_rpc_data_field field;
|
|
union di_rpc_data_value value;
|
|
};
|
|
|
|
/**
|
|
* RPC gps data
|
|
*/
|
|
struct di_rpc_sensor_data_gps {
|
|
uint16_t uid; /**< DI-Net RPC sensor uid */
|
|
bool fix; /**< Good fix */
|
|
uint64_t last_update; /**< Last good fix */
|
|
uint8_t fix_state; /**< State of GPS position fix @see di_drv_hl854x_gps_fix_state */
|
|
double latitude; /**< Latitude decimal notation */
|
|
double longitude; /**< Longitude decimal notation */
|
|
uint8_t siv; /**< Satellites in view count */
|
|
char hdop[5]; /**< Horizontal dilution of precision. E.g "00.0" */
|
|
};
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* INCLUDE_DI_RPC_STRUCTURES_H_ */
|