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

— setup/notification message codec. More...

#include "aliro_uwb_msg.h"
#include "aliro_uwb_msg_builder.h"
#include "aliro_uwb_msg_parser.h"
#include "aliro_uwb_msg_spec.h"
#include <aliro_uwb_adapter/aliro_uwb_adapter.h>
#include "aliro_round_config.h"
#include "woz_alloc.h"
#include <string.h>
#include "woz_log.h"
#include "woz_util.h"
Include dependency graph for aliro_uwb_msg.c:

Functions

void aliro_uwb_msg_free (struct aliro_uwb_message *message)
 Releases a message allocated by this layer's message builders.
 
struct aliro_uwb_messagealiro_uwb_msg_build_m1 (struct aliro_uwb_session *session)
 Builds the M1 ranging-session-setup message advertising configuration IDs, pulse-shape combos, channel bitmask, and session ID.
 
static struct aliro_uwb_messagealiro_uwb_msg_build_m3 (struct aliro_uwb_session *session)
 Builds the M3 ranging-parameters message, deriving RAN multiplier and chaps-per-slot from the M2-negotiated durations and committing the reader's MAC mode.
 
struct aliro_uwb_messagealiro_uwb_msg_build_suspend_resume_request (struct aliro_uwb_session *session, bool suspend)
 Builds a suspend or resume request message carrying the session identifier.
 
static struct aliro_uwb_messagealiro_uwb_msg_build_suspend_response (struct aliro_uwb_session *session, uint8_t status)
 Builds a suspend-response message carrying an accept or reject status.
 
struct aliro_uwb_messagealiro_uwb_msg_build_general_error (struct aliro_uwb_session *session, uint8_t error_code)
 Builds an Aliro general-error notification message carrying the given error code.
 
uint8_t aliro_uwb_msg_protocol_header (const uint8_t *bytes)
 Extracts the protocol type from byte 0 of an Aliro message header.
 
uint8_t aliro_uwb_msg_message_id (const uint8_t *bytes)
 Extracts the message type ID from byte 1 of an Aliro message header, used to dispatch M1-M4 setup and ranging messages during parsing.
 
uint16_t aliro_uwb_msg_payload_length (const uint8_t *bytes)
 Extracts the payload length from bytes 2-3 of an Aliro message header as a 16-bit big-endian integer.
 
static enum aliro_uwb_err parse_config_id (struct aliro_uwb_session *session, struct aliro_uwb_msg_attribute *attr)
 Parses the UWB configuration ID attribute from M2 and stores it in the session config.
 
static enum aliro_uwb_err parse_pulse_shape (struct aliro_uwb_session *session, struct aliro_uwb_msg_attribute *attr)
 Parses the pulse-shape-combo attribute from M2 and stores it in the session config.
 
static enum aliro_uwb_err parse_session_id (struct aliro_uwb_session *session, struct aliro_uwb_msg_attribute *attr)
 Parses the session-identifier attribute from M2 and verifies it matches the session's active session ID.
 
static enum aliro_uwb_err parse_channel (struct aliro_uwb_session *session, struct aliro_uwb_msg_attribute *attr)
 Parses the channel bitmask attribute from M2, mapping it to channel 5 or 9 in the session config.
 
static enum aliro_uwb_err parse_ran_multiplier (struct aliro_uwb_session *session, struct aliro_uwb_msg_attribute *attr)
 Parses the RAN multiplier attribute from M3, selecting the larger of the peer's value and the reader's minimum, and computes the ranging duration in milliseconds.
 
static enum aliro_uwb_err parse_slot_bitmask (struct aliro_uwb_session *session, struct aliro_uwb_msg_attribute *attr)
 Parses the slot bitmask attribute from M3, intersects it with the local capability bitmask, and maps the lowest common bit to a chaps-per-slot count to compute slot duration.
 
static enum aliro_uwb_err parse_sync_code_bitmask (struct aliro_uwb_session *session, struct aliro_uwb_msg_attribute *attr)
 Parses the sync code bitmask attribute from M2 and logs the peer's offered bitmask; the reader retains its own capability bitmask for M3 and does not update the session config.
 
static enum aliro_uwb_err parse_sync_code_index (struct aliro_uwb_session *session, struct aliro_uwb_msg_attribute *attr)
 Parses the sync code index attribute from M3 and stores it in the session config.
 
static enum aliro_uwb_err parse_hopping_bitmask (struct aliro_uwb_session *session, struct aliro_uwb_msg_attribute *attr)
 Parses the hopping configuration bitmask attribute from M2, intersects peer capabilities with local CCC capabilities, and selects the first mutually supported preferred hopping config.
 
static enum aliro_uwb_err parse_sts_index0 (struct aliro_uwb_session *session, struct aliro_uwb_msg_attribute *attr)
 Parses the STS index 0 attribute from M2 and stores it in the session config.
 
static enum aliro_uwb_err parse_uwb_time0 (struct aliro_uwb_session *session, struct aliro_uwb_msg_attribute *attr)
 Parses the UWB time 0 attribute from M2 and stores it as the session's initial UWB time.
 
static enum aliro_uwb_err parse_hop_mode_key (struct aliro_uwb_session *session, struct aliro_uwb_msg_attribute *attr)
 Parses the hop mode key attribute from M2 and stores the raw key bytes in the session config; unused downstream on this lock.
 
static enum aliro_uwb_err parse_status (struct aliro_uwb_msg_attribute *attr, uint8_t *status)
 Parses a status attribute from a ranging message into the given output parameter.
 
static enum aliro_uwb_err parse_session_attribute (struct aliro_uwb_msg_attribute *attr, struct aliro_uwb_session *session)
 Dispatches a ranging-service session attribute to its type-specific parser and applies it to the session; unknown attributes are logged and ignored.
 
static enum aliro_uwb_err parse_ranging (struct aliro_uwb_session *session, struct aliro_uwb_message *message, uint32_t *attr_mask, uint8_t *status)
 Parses all ranging-service attributes in a message, applying each to the session and recording which attributes were present.
 
static void compute_initiation_time (struct aliro_uwb_session *session)
 Sets the session's ranging initiation time from its time offset, using zero if unsynchronized or adding the offset to the existing UWB time otherwise.
 
static enum aliro_uwb_err set_resume_params (struct aliro_uwb_session *session)
 Sets the STS index and initiation time on the CCC session in preparation for re-arming ranging after a suspend.
 
static enum aliro_uwb_err handle_m2 (struct aliro_uwb_session *session, struct aliro_uwb_message *message)
 Handles an inbound M2 message by validating its attributes and session state, then building and transmitting M3 and advancing to the M3_SENT state.
 
static enum aliro_uwb_err handle_m4 (struct aliro_uwb_session *session, struct aliro_uwb_message *message)
 Handles an inbound M4 message by validating its attributes and session state, computing the ranging initiation time, initializing the session, and advancing to the RANGING state.
 
static enum aliro_uwb_err handle_suspend_request (struct aliro_uwb_session *session, struct aliro_uwb_message *message)
 Handles an inbound suspend request by validating session state, stopping the session, then building and transmitting a suspend response with acceptance or rejection status.
 
static enum aliro_uwb_err handle_suspend_response (struct aliro_uwb_session *session, struct aliro_uwb_message *message)
 Handles an inbound suspend response by validating its attributes and session state, stopping the session if accepted or returning to the RANGING state if rejected.
 
static enum aliro_uwb_err handle_resume_response (struct aliro_uwb_session *session, struct aliro_uwb_message *message)
 Handle an inbound resume response, arm timing and CCC state, and start ranging.
 
enum aliro_uwb_err aliro_uwb_msg_process_ranging (struct aliro_uwb_session *session, struct aliro_uwb_message *message)
 Dispatch an inbound ranging-phase message to its handler based on message type.
 
static enum aliro_uwb_err handle_init_ranging_later (struct aliro_uwb_session *session)
 Handle an "init ranging later" notification, returning the session to CREATED state.
 
static enum aliro_uwb_err handle_resume_later (struct aliro_uwb_session *session)
 Handle a "resume later" notification, moving the session to SUSPENDED without re-arming ranging.
 
static enum aliro_uwb_err handle_ranging_suspended (struct aliro_uwb_session *session)
 Handle a "ranging suspended" notification by stopping the session and moving it to SUSPENDED.
 
static enum aliro_uwb_err parse_event_notification (struct aliro_uwb_session *session, struct aliro_uwb_message *message)
 Parse an Aliro event notification message, logging busy, general-error, and reader-descriptor events.
 
static enum aliro_uwb_err parse_ranging_notification (struct aliro_uwb_session *session, struct aliro_uwb_message *message)
 Parse a ranging-setup notification message and dispatch each attribute to its session state handler.
 
enum aliro_uwb_err aliro_uwb_msg_process_notification (struct aliro_uwb_session *session, struct aliro_uwb_message *message)
 Dispatch a received notification message to its parser by message ID.
 
enum aliro_uwb_err aliro_uwb_msg_process_supplementary (struct aliro_uwb_session *session, struct aliro_uwb_message *message)
 Log every attribute of a Supplementary Service message (protocol 0x03).
 

Detailed Description

— setup/notification message codec.

Function Documentation

◆ aliro_uwb_msg_build_general_error()

struct aliro_uwb_message * aliro_uwb_msg_build_general_error ( struct aliro_uwb_session session,
uint8_t  error_code 
)

Builds an Aliro general-error notification message carrying the given error code.

Build a general-error message for the given session.

Parameters
sessionUnused; reserved for a consistent builder signature.
error_codeError code to encode in the general-error notification attribute.
Returns
Newly allocated notification message, or NULL if builder init or attribute encoding fails.

◆ aliro_uwb_msg_build_m1()

struct aliro_uwb_message * aliro_uwb_msg_build_m1 ( struct aliro_uwb_session session)

Builds the M1 ranging-session-setup message advertising configuration IDs, pulse-shape combos, channel bitmask, and session ID.

Parameters
sessionSession whose Aliro capabilities and session ID populate the message.
Returns
Newly allocated M1 message, or NULL if builder init or attribute encoding fails.

◆ aliro_uwb_msg_build_m3()

static struct aliro_uwb_message * aliro_uwb_msg_build_m3 ( struct aliro_uwb_session session)
static

Builds the M3 ranging-parameters message, deriving RAN multiplier and chaps-per-slot from the M2-negotiated durations and committing the reader's MAC mode.

Parameters
sessionSession whose negotiated M2 config and reader settings populate the M3 attributes.
Returns
Newly allocated M3 message, or NULL if builder init or attribute encoding fails.

◆ aliro_uwb_msg_build_suspend_response()

static struct aliro_uwb_message * aliro_uwb_msg_build_suspend_response ( struct aliro_uwb_session session,
uint8_t  status 
)
static

Builds a suspend-response message carrying an accept or reject status.

Parameters
sessionUnused; reserved for a consistent builder signature.
statusResponse status; must be ALIRO_UWB_RANGING_SERVICE_STATUS_ACCEPT or ALIRO_UWB_RANGING_SERVICE_STATUS_REJECT.
Returns
Newly allocated suspend-response message, or NULL if status is invalid, or if builder init or attribute encoding fails.

◆ aliro_uwb_msg_build_suspend_resume_request()

struct aliro_uwb_message * aliro_uwb_msg_build_suspend_resume_request ( struct aliro_uwb_session session,
bool  suspend 
)

Builds a suspend or resume request message carrying the session identifier.

Parameters
sessionSession whose session ID is encoded into the message.
suspendTrue to build a suspend request, false to build a resume request.
Returns
Newly allocated request message, or NULL if builder init or attribute encoding fails.

◆ aliro_uwb_msg_free()

void aliro_uwb_msg_free ( struct aliro_uwb_message message)

Releases a message allocated by this layer's message builders.

Release a message built by this layer.

◆ aliro_uwb_msg_message_id()

uint8_t aliro_uwb_msg_message_id ( const uint8_t *  bytes)

Extracts the message type ID from byte 1 of an Aliro message header, used to dispatch M1-M4 setup and ranging messages during parsing.

Parameters
bytesPointer to the start of the raw message bytes.
Returns
The message ID byte.

◆ aliro_uwb_msg_payload_length()

uint16_t aliro_uwb_msg_payload_length ( const uint8_t *  bytes)

Extracts the payload length from bytes 2-3 of an Aliro message header as a 16-bit big-endian integer.

Parameters
bytesPointer to the start of the raw message bytes.
Returns
The payload length in bytes.

◆ aliro_uwb_msg_process_notification()

enum aliro_uwb_err aliro_uwb_msg_process_notification ( struct aliro_uwb_session session,
struct aliro_uwb_message message 
)

Dispatch a received notification message to its parser by message ID.

Reader-status notifications are informational and ignored; unknown IDs are logged and ignored.

Parameters
sessionAliro UWB session to update with the parsed notification's effects.
messageReceived notification message to dispatch.
Returns
ALIRO_UWB_ERR_NONE for handled, informational and unknown notifications, otherwise the error from the event or ranging parser.

◆ aliro_uwb_msg_process_ranging()

enum aliro_uwb_err aliro_uwb_msg_process_ranging ( struct aliro_uwb_session session,
struct aliro_uwb_message message 
)

Dispatch an inbound ranging-phase message to its handler based on message type.

Parameters
sessionAliro UWB session to update.
messageReceived ranging message to dispatch.
Returns
Handler's result on success; ALIRO_UWB_ERR_INVALID_PARAMETER if session or message is NULL; ALIRO_UWB_ERR_MESSAGE_UNSUPPORTED for unknown message types.

◆ aliro_uwb_msg_process_supplementary()

enum aliro_uwb_err aliro_uwb_msg_process_supplementary ( struct aliro_uwb_session session,
struct aliro_uwb_message message 
)

Log every attribute of a Supplementary Service message (protocol 0x03).

The phone sends one of these at session establishment. Nothing is modelled yet and no response is emitted, so this only surfaces the payload: the semantics are unknown and are being characterised by diffing the attributes across conditions.

Parameters
sessionAliro UWB session (unused; no state is driven from here yet).
messageReceived supplementary-service message to log.
Returns
ALIRO_UWB_ERR_NONE always.

◆ aliro_uwb_msg_protocol_header()

uint8_t aliro_uwb_msg_protocol_header ( const uint8_t *  bytes)

Extracts the protocol type from byte 0 of an Aliro message header.

Parameters
bytesPointer to the start of the raw message bytes.
Returns
The protocol type byte.

◆ compute_initiation_time()

static void compute_initiation_time ( struct aliro_uwb_session session)
static

Sets the session's ranging initiation time from its time offset, using zero if unsynchronized or adding the offset to the existing UWB time otherwise.

Parameters
sessionSession whose config's uwb_time_us is updated in place.

◆ handle_init_ranging_later()

static enum aliro_uwb_err handle_init_ranging_later ( struct aliro_uwb_session session)
static

Handle an "init ranging later" notification, returning the session to CREATED state.

Parameters
sessionAliro UWB session expected to be in M1_SENT state.
Returns
ALIRO_UWB_ERR_NONE on success; ALIRO_UWB_ERR_INVALID_STATE if the session is not in M1_SENT.

◆ handle_m2()

static enum aliro_uwb_err handle_m2 ( struct aliro_uwb_session session,
struct aliro_uwb_message message 
)
static

Handles an inbound M2 message by validating its attributes and session state, then building and transmitting M3 and advancing to the M3_SENT state.

Parameters
sessionSession receiving the M2 message.
messageInbound M2 message to process.
Returns
ALIRO_UWB_ERR_NONE on success, or an error if parsing, attributes, state, or M3 construction fail.

◆ handle_m4()

static enum aliro_uwb_err handle_m4 ( struct aliro_uwb_session session,
struct aliro_uwb_message message 
)
static

Handles an inbound M4 message by validating its attributes and session state, computing the ranging initiation time, initializing the session, and advancing to the RANGING state.

Parameters
sessionSession receiving the M4 message.
messageInbound M4 message to process.
Returns
ALIRO_UWB_ERR_NONE on success, or an error if parsing, attributes, state, or session initialization fail.

◆ handle_ranging_suspended()

static enum aliro_uwb_err handle_ranging_suspended ( struct aliro_uwb_session session)
static

Handle a "ranging suspended" notification by stopping the session and moving it to SUSPENDED.

Parameters
sessionAliro UWB session expected to be in RANGING state.
Returns
ALIRO_UWB_ERR_NONE on success; ALIRO_UWB_ERR_INVALID_STATE if the session is not in RANGING; otherwise the result of stopping the session.

◆ handle_resume_later()

static enum aliro_uwb_err handle_resume_later ( struct aliro_uwb_session session)
static

Handle a "resume later" notification, moving the session to SUSPENDED without re-arming ranging.

Parameters
sessionAliro UWB session expected to be in RESUME_REQ_SENT state.
Returns
ALIRO_UWB_ERR_NONE on success; ALIRO_UWB_ERR_INVALID_STATE if the session is not in RESUME_REQ_SENT.

◆ handle_resume_response()

static enum aliro_uwb_err handle_resume_response ( struct aliro_uwb_session session,
struct aliro_uwb_message message 
)
static

Handle an inbound resume response, arm timing and CCC state, and start ranging.

Parameters
sessionAliro UWB session expected to be in RESUME_REQ_SENT state.
messageReceived resume response message to validate and parse.
Returns
ALIRO_UWB_ERR_NONE on success; an error if attributes are missing, state is wrong, or resume setup/session start fails.

◆ handle_suspend_request()

static enum aliro_uwb_err handle_suspend_request ( struct aliro_uwb_session session,
struct aliro_uwb_message message 
)
static

Handles an inbound suspend request by validating session state, stopping the session, then building and transmitting a suspend response with acceptance or rejection status.

Parameters
sessionSession receiving the suspend request.
messageInbound suspend-request message to process.
Returns
ALIRO_UWB_ERR_NONE on success, or an error if parsing, attributes, state, or response construction fail.

◆ handle_suspend_response()

static enum aliro_uwb_err handle_suspend_response ( struct aliro_uwb_session session,
struct aliro_uwb_message message 
)
static

Handles an inbound suspend response by validating its attributes and session state, stopping the session if accepted or returning to the RANGING state if rejected.

Parameters
sessionSession receiving the suspend response.
messageInbound suspend-response message to process.
Returns
ALIRO_UWB_ERR_NONE on success, or an error if parsing, attributes, or state validation fail.

◆ parse_channel()

static enum aliro_uwb_err parse_channel ( struct aliro_uwb_session session,
struct aliro_uwb_msg_attribute attr 
)
static

Parses the channel bitmask attribute from M2, mapping it to channel 5 or 9 in the session config.

Parameters
sessionSession whose config receives the resolved channel number.
attrAttribute to parse.
Returns
ALIRO_UWB_ERR_NONE on success, ALIRO_UWB_ERR_MSG_MALFORMED if the value cannot be read, or ALIRO_UWB_ERR_INVALID_PARAMETER for an unsupported bitmask.

◆ parse_config_id()

static enum aliro_uwb_err parse_config_id ( struct aliro_uwb_session session,
struct aliro_uwb_msg_attribute attr 
)
static

Parses the UWB configuration ID attribute from M2 and stores it in the session config.

Parameters
sessionSession whose config receives the parsed configuration ID.
attrAttribute to parse.
Returns
ALIRO_UWB_ERR_NONE on success, or ALIRO_UWB_ERR_MSG_MALFORMED if the value cannot be read.

◆ parse_event_notification()

static enum aliro_uwb_err parse_event_notification ( struct aliro_uwb_session session,
struct aliro_uwb_message message 
)
static

Parse an Aliro event notification message, logging busy, general-error, and reader-descriptor events.

Parameters
sessionAliro UWB session (unused).
messageReceived event notification message to parse.
Returns
ALIRO_UWB_ERR_NONE on success; ALIRO_UWB_ERR_MSG_MALFORMED if a general-error attribute has the wrong length.

◆ parse_hop_mode_key()

static enum aliro_uwb_err parse_hop_mode_key ( struct aliro_uwb_session session,
struct aliro_uwb_msg_attribute attr 
)
static

Parses the hop mode key attribute from M2 and stores the raw key bytes in the session config; unused downstream on this lock.

Parameters
sessionSession whose config receives the parsed hop mode key.
attrAttribute to parse.
Returns
ALIRO_UWB_ERR_NONE on success, or ALIRO_UWB_ERR_MSG_MALFORMED if the value cannot be read.

◆ parse_hopping_bitmask()

static enum aliro_uwb_err parse_hopping_bitmask ( struct aliro_uwb_session session,
struct aliro_uwb_msg_attribute attr 
)
static

Parses the hopping configuration bitmask attribute from M2, intersects peer capabilities with local CCC capabilities, and selects the first mutually supported preferred hopping config.

Parameters
sessionSession whose reader preferences are matched and whose config receives the selected hopping mode.
attrAttribute to parse.
Returns
ALIRO_UWB_ERR_NONE on success, ALIRO_UWB_ERR_MSG_MALFORMED if the value cannot be read or no common hopping config is found.

◆ parse_pulse_shape()

static enum aliro_uwb_err parse_pulse_shape ( struct aliro_uwb_session session,
struct aliro_uwb_msg_attribute attr 
)
static

Parses the pulse-shape-combo attribute from M2 and stores it in the session config.

Parameters
sessionSession whose config receives the parsed pulse shape.
attrAttribute to parse.
Returns
ALIRO_UWB_ERR_NONE on success, or ALIRO_UWB_ERR_MSG_MALFORMED if the value cannot be read.

◆ parse_ran_multiplier()

static enum aliro_uwb_err parse_ran_multiplier ( struct aliro_uwb_session session,
struct aliro_uwb_msg_attribute attr 
)
static

Parses the RAN multiplier attribute from M3, selecting the larger of the peer's value and the reader's minimum, and computes the ranging duration in milliseconds.

Parameters
sessionSession whose config receives the computed ranging duration.
attrAttribute to parse.
Returns
ALIRO_UWB_ERR_NONE on success, or ALIRO_UWB_ERR_MSG_MALFORMED if the value cannot be read.

◆ parse_ranging()

static enum aliro_uwb_err parse_ranging ( struct aliro_uwb_session session,
struct aliro_uwb_message message,
uint32_t *  attr_mask,
uint8_t *  status 
)
static

Parses all ranging-service attributes in a message, applying each to the session and recording which attributes were present.

Parameters
sessionSession updated by attribute-specific parsers.
messageMessage whose attributes are parsed.
attr_maskOutput parameter receiving a bitmask of attribute IDs present in the message.
statusOutput parameter receiving the parsed status, or ALIRO_UWB_RANGING_SERVICE_STATUS_UNKNOWN if no status attribute is present.
Returns
ALIRO_UWB_ERR_NONE on success, or the first parsing error encountered.

◆ parse_ranging_notification()

static enum aliro_uwb_err parse_ranging_notification ( struct aliro_uwb_session session,
struct aliro_uwb_message message 
)
static

Parse a ranging-setup notification message and dispatch each attribute to its session state handler.

Parameters
sessionAliro UWB session to update.
messageReceived ranging notification message to parse.
Returns
ALIRO_UWB_ERR_NONE on success; the first handler error encountered otherwise.

◆ parse_session_attribute()

static enum aliro_uwb_err parse_session_attribute ( struct aliro_uwb_msg_attribute attr,
struct aliro_uwb_session session 
)
static

Dispatches a ranging-service session attribute to its type-specific parser and applies it to the session; unknown attributes are logged and ignored.

Parameters
attrAttribute to parse and apply.
sessionSession updated by the attribute-specific parser.
Returns
ALIRO_UWB_ERR_NONE on success or for ignored/unknown attributes, otherwise the error from the specific parser.

◆ parse_session_id()

static enum aliro_uwb_err parse_session_id ( struct aliro_uwb_session session,
struct aliro_uwb_msg_attribute attr 
)
static

Parses the session-identifier attribute from M2 and verifies it matches the session's active session ID.

Parameters
sessionSession whose session ID is checked against the parsed value.
attrAttribute to parse.
Returns
ALIRO_UWB_ERR_NONE on success, ALIRO_UWB_ERR_MSG_MALFORMED if the value cannot be read, or ALIRO_UWB_ERR_INVALID_PARAMETER on a session ID mismatch.

◆ parse_slot_bitmask()

static enum aliro_uwb_err parse_slot_bitmask ( struct aliro_uwb_session session,
struct aliro_uwb_msg_attribute attr 
)
static

Parses the slot bitmask attribute from M3, intersects it with the local capability bitmask, and maps the lowest common bit to a chaps-per-slot count to compute slot duration.

Parameters
sessionSession whose config receives the computed slot duration.
attrAttribute to parse.
Returns
ALIRO_UWB_ERR_NONE on success, or ALIRO_UWB_ERR_MSG_MALFORMED if the value cannot be read.

◆ parse_status()

static enum aliro_uwb_err parse_status ( struct aliro_uwb_msg_attribute attr,
uint8_t *  status 
)
static

Parses a status attribute from a ranging message into the given output parameter.

Parameters
attrAttribute to parse.
statusOutput parameter receiving the parsed 8-bit status value.
Returns
ALIRO_UWB_ERR_NONE on success, or ALIRO_UWB_ERR_MSG_MALFORMED if the value cannot be read.

◆ parse_sts_index0()

static enum aliro_uwb_err parse_sts_index0 ( struct aliro_uwb_session session,
struct aliro_uwb_msg_attribute attr 
)
static

Parses the STS index 0 attribute from M2 and stores it in the session config.

Parameters
sessionSession whose config receives the parsed STS index.
attrAttribute to parse.
Returns
ALIRO_UWB_ERR_NONE on success, or ALIRO_UWB_ERR_MSG_MALFORMED if the value cannot be read.

◆ parse_sync_code_bitmask()

static enum aliro_uwb_err parse_sync_code_bitmask ( struct aliro_uwb_session session,
struct aliro_uwb_msg_attribute attr 
)
static

Parses the sync code bitmask attribute from M2 and logs the peer's offered bitmask; the reader retains its own capability bitmask for M3 and does not update the session config.

Parameters
sessionUnused; reserved for a consistent parser signature.
attrAttribute to parse.
Returns
ALIRO_UWB_ERR_NONE on success, or ALIRO_UWB_ERR_MSG_MALFORMED if the value cannot be read.

◆ parse_sync_code_index()

static enum aliro_uwb_err parse_sync_code_index ( struct aliro_uwb_session session,
struct aliro_uwb_msg_attribute attr 
)
static

Parses the sync code index attribute from M3 and stores it in the session config.

Parameters
sessionSession whose config receives the parsed sync code index.
attrAttribute to parse.
Returns
ALIRO_UWB_ERR_NONE on success, or ALIRO_UWB_ERR_MSG_MALDORMED if the value cannot be read.

◆ parse_uwb_time0()

static enum aliro_uwb_err parse_uwb_time0 ( struct aliro_uwb_session session,
struct aliro_uwb_msg_attribute attr 
)
static

Parses the UWB time 0 attribute from M2 and stores it as the session's initial UWB time.

Parameters
sessionSession whose config receives the parsed UWB time.
attrAttribute to parse.
Returns
ALIRO_UWB_ERR_NONE on success, or ALIRO_UWB_ERR_MSG_MALFORMED if the value cannot be read.

◆ set_resume_params()

static enum aliro_uwb_err set_resume_params ( struct aliro_uwb_session session)
static

Sets the STS index and initiation time on the CCC session in preparation for re-arming ranging after a suspend.

Parameters
sessionSession whose CCC session and Aliro config supply the resume parameters.
Returns
ALIRO_UWB_ERR_NONE on success, or ALIRO_UWB_ERR_INTERNAL if either CCC call fails.