modules/woz_uwb/src/aliro/aliro_uwb_msg_builder.c
asxeem/openaliro
Module
aliro_uwb_msg_builder.c
big-endian TLV message builder.
Overview
big-endian TLV message builder.
depends on aliro_uwb_msg_builder.h woz_alloc.h
API
Fbool aliro_uwb_msg_builder_init(struct aliro_uwb_msg_builder *builder, uint16_t payload_len)
modules/woz_uwb/src/aliro/aliro_uwb_msg_builder.c:14
Allocate a message with room for the given payload length plus header.
builder- Message builder to initialize.
payload_len- Number of payload bytes to reserve, in addition to the header.
- returns
- true on successful allocation, false if allocation failed.
Fvoid aliro_uwb_msg_builder_header(struct aliro_uwb_msg_builder *builder, uint8_t protocol, uint8_t id, uint16_t payload_length)
modules/woz_uwb/src/aliro/aliro_uwb_msg_builder.c:34
Append the 4-byte header (protocol, id, big-endian payload length).
builder- Message builder to append the header to.
protocol- Protocol identifier byte.
id- Message identifier byte.
payload_length- Payload length, written big-endian.
Fstatic bool add_attribute(struct aliro_uwb_msg_builder *builder, uint8_t id, uint8_t length, const uint8_t *value)
modules/woz_uwb/src/aliro/aliro_uwb_msg_builder.c:53
Append id + length + raw value bytes, refusing to overrun the allocation.
builder- Message builder to append the attribute to.
id- Attribute identifier byte.
length- Length of the attribute value in bytes.
value- Pointer to the attribute value bytes to copy, may be NULL if length is 0.
- returns
- true if the attribute was appended, false if it would overrun the builder's capacity.
called by
aliro_uwb_msg_builder_add_bytes, aliro_uwb_msg_builder_add_u16, aliro_uwb_msg_builder_add_u16_array, aliro_uwb_msg_builder_add_u32, aliro_uwb_msg_builder_add_u64, aliro_uwb_msg_builder_add_u8Fbool aliro_uwb_msg_builder_add_u8(struct aliro_uwb_msg_builder *builder, uint8_t id, uint8_t value)
modules/woz_uwb/src/aliro/aliro_uwb_msg_builder.c:78
Append a 1-byte-value attribute.
builder- Message builder to append the attribute to.
id- Attribute identifier byte.
value- 1-byte value to append.
- returns
- true if the attribute was appended, false if it would overrun the builder's capacity.
calls
add_attributeFbool aliro_uwb_msg_builder_add_u16(struct aliro_uwb_msg_builder *builder, uint8_t id, uint16_t value)
modules/woz_uwb/src/aliro/aliro_uwb_msg_builder.c:90
Append a 2-byte big-endian attribute.
builder- Message builder to append the attribute to.
id- Attribute identifier byte.
value- 16-bit value to append, encoded big-endian.
- returns
- true if the attribute was appended, false if it would overrun the builder's capacity.
calls
add_attributeFbool aliro_uwb_msg_builder_add_u32(struct aliro_uwb_msg_builder *builder, uint8_t id, uint32_t value)
modules/woz_uwb/src/aliro/aliro_uwb_msg_builder.c:105
Append a 4-byte big-endian attribute.
builder- Message builder to append the attribute to.
id- Attribute identifier byte.
value- 32-bit value to append, encoded big-endian.
- returns
- true if the attribute was appended, false if it would overrun the builder's capacity.
calls
add_attributeFbool aliro_uwb_msg_builder_add_u64(struct aliro_uwb_msg_builder *builder, uint8_t id, uint64_t value)
modules/woz_uwb/src/aliro/aliro_uwb_msg_builder.c:125
Append a 8-byte big-endian attribute.
builder- Message builder to append the attribute to.
id- Attribute identifier byte.
value- 64-bit value to append, encoded big-endian.
- returns
- true if the attribute was appended, false if it would overrun the builder's capacity.
calls
add_attributeFbool aliro_uwb_msg_builder_add_u16_array(struct aliro_uwb_msg_builder *builder, uint8_t id, size_t count, const uint16_t *values)
modules/woz_uwb/src/aliro/aliro_uwb_msg_builder.c:146
Append an attribute whose value is count big-endian 16-bit words.
builder- Message builder to append the attribute to.
id- Attribute identifier byte.
count- Number of 16-bit words in the values array.
values- Pointer to the array of 16-bit values to append.
- returns
- true if the attribute was appended, false if count is 0, values is NULL, or the attribute would overrun the builder's capacity.
calls
add_attributeFbool aliro_uwb_msg_builder_add_bytes(struct aliro_uwb_msg_builder *builder, uint8_t id, size_t count, const uint8_t *values)
modules/woz_uwb/src/aliro/aliro_uwb_msg_builder.c:167
Append an attribute whose value is count raw bytes.
calls
add_attribute