feat(setprotocol): define system payload schemas
This commit is contained in:
@@ -23,6 +23,12 @@ extern "C" {
|
||||
#define SETP_NODE_LOCAL 0x0000U
|
||||
#define SETP_NODE_BROADCAST 0xFFFFU
|
||||
|
||||
#define SETP_DEVICE_INFO_SCHEMA_VERSION 1U
|
||||
#define SETP_DEVICE_INFO_FIXED_SIZE 25U
|
||||
#define SETP_DEVICE_MODEL_MAX 63U
|
||||
#define SETP_CAPABILITIES_SCHEMA_VERSION 1U
|
||||
#define SETP_CAPABILITIES_SIZE 20U
|
||||
|
||||
/* Frame flags. Reserved bits must be transmitted as zero. */
|
||||
#define SETP_FLAG_RESPONSE 0x01U
|
||||
#define SETP_FLAG_EVENT 0x02U
|
||||
@@ -86,6 +92,40 @@ typedef enum {
|
||||
SETP_STATUS_WRONG_STATE = 15
|
||||
} setp_status_t;
|
||||
|
||||
/* CAPABILITIES feature_flags. */
|
||||
#define SETP_FEATURE_READ (1UL << 0)
|
||||
#define SETP_FEATURE_WRITE (1UL << 1)
|
||||
#define SETP_FEATURE_CATALOG (1UL << 2)
|
||||
#define SETP_FEATURE_SUBSCRIBE (1UL << 3)
|
||||
#define SETP_FEATURE_LOG_READ (1UL << 4)
|
||||
#define SETP_FEATURE_FIRMWARE (1UL << 5)
|
||||
#define SETP_FEATURE_DIAGNOSTICS (1UL << 6)
|
||||
|
||||
/* CAPABILITIES interface_mask; bit index equals setp_iface_t. */
|
||||
#define SETP_IFACE_MASK(iface) (1UL << (uint32_t)(iface))
|
||||
|
||||
typedef struct {
|
||||
uint16_t schema_version;
|
||||
uint16_t device_class;
|
||||
uint32_t hardware_version;
|
||||
uint32_t firmware_version;
|
||||
uint32_t dictionary_version;
|
||||
uint64_t serial_number;
|
||||
uint8_t model_length;
|
||||
const uint8_t *model;
|
||||
} setp_device_info_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t schema_version;
|
||||
uint16_t max_payload;
|
||||
uint32_t interface_mask;
|
||||
uint32_t feature_flags;
|
||||
uint16_t max_read_items;
|
||||
uint16_t max_write_items;
|
||||
uint16_t max_subscriptions;
|
||||
uint16_t max_publish_items;
|
||||
} setp_capabilities_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t flags;
|
||||
uint16_t message_type;
|
||||
@@ -116,8 +156,10 @@ typedef void (*setp_frame_fn)(const setp_frame_t *frame, void *user);
|
||||
|
||||
uint16_t setp_get_u16(const uint8_t *data);
|
||||
uint32_t setp_get_u32(const uint8_t *data);
|
||||
uint64_t setp_get_u64(const uint8_t *data);
|
||||
void setp_put_u16(uint8_t *data, uint16_t value);
|
||||
void setp_put_u32(uint8_t *data, uint32_t value);
|
||||
void setp_put_u64(uint8_t *data, uint64_t value);
|
||||
|
||||
uint32_t setp_crc32(const uint8_t *data, size_t length);
|
||||
|
||||
@@ -141,6 +183,18 @@ size_t setp_status_encode(uint16_t status, uint8_t *out, size_t capacity);
|
||||
bool setp_status_decode(const setp_frame_t *frame, uint16_t *status,
|
||||
const uint8_t **body, uint16_t *body_length);
|
||||
|
||||
/** Encode/decode DEVICE_INFO response body (without the status prefix). */
|
||||
size_t setp_device_info_encode(const setp_device_info_t *info,
|
||||
uint8_t *out, size_t capacity);
|
||||
bool setp_device_info_decode(const uint8_t *data, uint16_t length,
|
||||
setp_device_info_t *out);
|
||||
|
||||
/** Encode/decode CAPABILITIES response body (without the status prefix). */
|
||||
size_t setp_capabilities_encode(const setp_capabilities_t *capabilities,
|
||||
uint8_t *out, size_t capacity);
|
||||
bool setp_capabilities_decode(const uint8_t *data, uint16_t length,
|
||||
setp_capabilities_t *out);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user