openaliro
Aliro reader: UWB/CCC core and ESP32-S3/C5/C6 port
Loading...
Searching...
No Matches
aliro_uwb_msg_parser.c File Reference

— TLV attribute parser and big-endian reads. More...

#include "aliro_uwb_msg_parser.h"
#include "woz_log.h"
Include dependency graph for aliro_uwb_msg_parser.c:

Functions

struct aliro_uwb_msg_attributealiro_uwb_msg_next_attribute (struct aliro_uwb_msg_parser *parser)
 Parses the next TLV attribute from the message payload; returns NULL if offset exceeds declared message length, clamping to prevent overrun.
 
static bool read_be (const struct aliro_uwb_msg_attribute *attr, const char *name, uint8_t width, uint64_t *out)
 Decodes a big-endian fixed-width integer from an attribute; returns false if declared length does not match width or on parse error.
 
bool aliro_uwb_msg_read_u8 (const struct aliro_uwb_msg_attribute *attr, const char *name, uint8_t *out)
 Decodes an 8-bit big-endian integer from an attribute; returns false on width mismatch or parse error.
 
bool aliro_uwb_msg_read_u16 (const struct aliro_uwb_msg_attribute *attr, const char *name, uint16_t *out)
 Decodes a 16-bit big-endian integer from an attribute; returns false on width mismatch or parse error.
 
bool aliro_uwb_msg_read_u32 (const struct aliro_uwb_msg_attribute *attr, const char *name, uint32_t *out)
 Decodes a 32-bit big-endian integer from an attribute; returns false on width mismatch or parse error.
 
bool aliro_uwb_msg_read_u64 (const struct aliro_uwb_msg_attribute *attr, const char *name, uint64_t *out)
 Decodes a 64-bit big-endian integer from an attribute.
 

Detailed Description

— TLV attribute parser and big-endian reads.

Function Documentation

◆ aliro_uwb_msg_next_attribute()

struct aliro_uwb_msg_attribute * aliro_uwb_msg_next_attribute ( struct aliro_uwb_msg_parser parser)

Parses the next TLV attribute from the message payload; returns NULL if offset exceeds declared message length, clamping to prevent overrun.

Advance to the next attribute; NULL at end-of-payload or on overrun.

Parameters
parserParser cursor to advance.
Returns
The next attribute, or NULL at end-of-payload or on overrun.

◆ aliro_uwb_msg_read_u16()

bool aliro_uwb_msg_read_u16 ( const struct aliro_uwb_msg_attribute attr,
const char *  name,
uint16_t *  out 
)

Decodes a 16-bit big-endian integer from an attribute; returns false on width mismatch or parse error.

Parameters
attrAttribute whose value bytes are decoded.
nameAttribute name, used for error logging.
outDestination for the decoded value.
Returns
true on success, false on a size mismatch.

◆ aliro_uwb_msg_read_u32()

bool aliro_uwb_msg_read_u32 ( const struct aliro_uwb_msg_attribute attr,
const char *  name,
uint32_t *  out 
)

Decodes a 32-bit big-endian integer from an attribute; returns false on width mismatch or parse error.

Parameters
attrAttribute whose value bytes are decoded.
nameAttribute name, used for error logging.
outDestination for the decoded value.
Returns
true on success, false on a size mismatch.

◆ aliro_uwb_msg_read_u64()

bool aliro_uwb_msg_read_u64 ( const struct aliro_uwb_msg_attribute attr,
const char *  name,
uint64_t *  out 
)

Decodes a 64-bit big-endian integer from an attribute.

Parameters
attrAttribute holding the encoded value.
nameAttribute name, used only in the mismatch log line.
outReceives the decoded value on success.
Returns
true on success, false on a width mismatch or parse error.

◆ aliro_uwb_msg_read_u8()

bool aliro_uwb_msg_read_u8 ( const struct aliro_uwb_msg_attribute attr,
const char *  name,
uint8_t *  out 
)

Decodes an 8-bit big-endian integer from an attribute; returns false on width mismatch or parse error.

Parameters
attrAttribute whose value bytes are decoded.
nameAttribute name, used for error logging.
outDestination for the decoded value.
Returns
true on success, false on a size mismatch.

◆ read_be()

static bool read_be ( const struct aliro_uwb_msg_attribute attr,
const char *  name,
uint8_t  width,
uint64_t *  out 
)
static

Decodes a big-endian fixed-width integer from an attribute; returns false if declared length does not match width or on parse error.

Parameters
attrAttribute whose value bytes are decoded.
nameAttribute name, used for error logging.
widthExpected byte width of the encoded integer.
outDestination for the decoded value.
Returns
true on success, false if the attribute's declared length does not match width.