Documentation
Includes
tuya_cloud_types.h
#include "tuya_cloud_types.h"
Macros
Marco __C_TLV_H__
#define __C_TLV_H__
Marco UINT8(ptr)
#define UINT8(ptr) ((UINT8_T *)(ptr))
Marco INT8(ptr)
#define INT8(ptr) ((INT8_T *)(ptr))
Marco UINT16(ptr)
#define UINT16(ptr) ((UINT16_T *)(ptr))
Marco INT16(ptr)
#define INT16(ptr) ((INT16_T *)(ptr))
Marco UINT32(ptr)
#define UINT32(ptr) ((UINT_T *)(ptr))
Marco INT32(ptr)
#define INT32(ptr) ((INT_T *)(ptr))
Marco PACKED
#define PACKED __attribute__((packed))
Marco PUT8(ptr, c)
#define PUT8(ptr, c) (*UINT8((ptr)) = (UINT8_T)(c))
Marco PUT16(ptr, s)
#define PUT16(ptr, s) (*UINT16((ptr)) = (UINT16_T)(s))
Marco PUT32(ptr, l)
#define PUT32(ptr, l) (*UINT32((ptr)) = (UINT_T)(l))
Marco GET_UINT8(ptr)
#define GET_UINT8(ptr) (*UINT8((ptr)))
Marco GET_INT8(ptr)
#define GET_INT8(ptr) (*INT8((ptr)))
Marco GET_UINT16(ptr)
#define GET_UINT16(ptr) (*UINT16((ptr)))
Marco GET_INT16(ptr)
#define GET_INT16(ptr) (*INT16((ptr)))
Marco GET_UINT32(ptr)
#define GET_UINT32(ptr) (*UINT32((ptr)))
Marco GET_INT32(ptr)
#define GET_INT32(ptr) (*INT32((ptr)))
Marco ADVANCE8(ptr)
#define ADVANCE8(ptr) ptr = (UINT8(UINT8((ptr)) + 1))
Marco ADVANCE16(ptr)
#define ADVANCE16(ptr) ptr = (UINT8(UINT16((ptr)) + 1))
Marco ADVANCE32(ptr)
#define ADVANCE32(ptr) ptr = (UINT8(UINT32((ptr)) + 1))
Marco MSG_MAGIC
#define MSG_MAGIC (305419896)
Marco MSG_AVAILABLE_TLVS(msg)
#define MSG_AVAILABLE_TLVS(msg) (((msg)->capacity) - ((msg)->nitems))
Marco MSG_TLV(msg, index)
#define MSG_TLV(msg, index) (&((msg)->tlvs[(index)]))
Marco MSG_LAST_TLV(msg)
#define MSG_LAST_TLV(msg) (MSG_TLV((msg), (msg)->nitems)) //last unvalid tlv element
Marco MSG_SIZE(msg)
#define MSG_SIZE(msg) ((UINT16_T)(SIZEOF(message_t) + SIZEOF(tlv_t) * (msg)->capacity))
Functions
Func msg_free
VOID msg_free(message_t *msg);
Func msg_get_packed_size
UINT_T msg_get_packed_size(message_t * msg);
Func msg_print
VOID msg_print(message_t * msg);
Func msg_pack
OPERATE_RET msg_pack(message_t *msg, UINT8_T *out, UINT_T *out_size);
Vars
Variable message_t
message_t * msg_init(UINT_T max_items);
Variable tlv_t
tlv_t * msg_append(message_t *msg, tlv_type_t type, UINT16_T id, VOID *value, UINT16_T length);
Variable message_t
message_t * msg_unpack(UINT8_T *packed, UINT_T size);
Consts
Types
Typedefs
Typedef tlv_type_t;
typedef enum {
TLV_TYPE_INT8 = 7,
TLV_TYPE_UINT8 = 8,
TLV_TYPE_INT16 = 9,
TLV_TYPE_UINT16 = 10,
TLV_TYPE_INT32 = 11,
TLV_TYPE_UINT32 = 12,
TLV_TYPE_BYTES = 13,
TLV_TYPE_MSG = 14, //Compound nested structure
} tlv_type_t;
Typedef tlv_t;
typedef struct {
UINT16_T id;
UINT16_T type;
UINT16_T length;
UINT8_T * value;
} PACKED tlv_t;
Typedef message_t;
typedef struct {
UINT_T magic;
UINT_T nitems;
UINT_T capacity;
tlv_t tlvs[0];
} PACKED message_t;