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

— message framing accessors, dispatch and builders. More...

#include "aliro_uwb_internal.h"
#include <aliro_uwb_adapter/aliro_uwb_session.h>
#include <stdint.h>
Include dependency graph for aliro_uwb_msg.h:

Go to the source code of this file.

Functions

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.
 
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.
 
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).
 
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.
 
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.
 
struct aliro_uwb_messagealiro_uwb_msg_build_general_error (struct aliro_uwb_session *session, uint8_t error_code)
 Build a general-error message for the given session.
 
void aliro_uwb_msg_free (struct aliro_uwb_message *message)
 Release a message built by this layer.
 

Detailed Description

— message framing accessors, dispatch and builders.

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 
)

Build a general-error message for the given session.

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_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)

Release a message built by this layer.

Parameters
messageMessage to free.

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.