modules/woz_uwb/src/aliro/aliro_uwb_session.c
asxeem/openaliro
Module

aliro_uwb_session.c

per-session lifecycle and state machine.

modules/woz_uwb/src/aliro/aliro_uwb_session.c18 documented symbols

Overview

per-session lifecycle and state machine.

depends on woz_log.h aliro_uwb_internal.h aliro_uwb_msg.h aliro_uwb_msg_spec.h aliro_uwb_session.h cherry_ccc.h woz_alloc.h

flowchart TD
  aliro_ccc_cb --> notify_error

API

Fstatic enum aliro_uwb_err notify_error(struct aliro_uwb_session *session)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:25

Send a general-error notification to the peer.

session
Session on which to build and transmit the error message.
returns
ALIRO_UWB_ERR_NONE on success, ALIRO_UWB_ERR_INVALID_PARAMETER if session is NULL, or ALIRO_UWB_ERR_INTERNAL if the message could not be built.
called by aliro_ccc_cb

Fstatic void aliro_ccc_cb(struct cherry_ccc_event *event, void *user_data)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:46

CCC seam callback: wrap the CCC event and forward it to the client.

event
CCC event to wrap and forward.
user_data
Aliro UWB session that owns the callback and client data.
calls notify_error

Fstatic void session_close(struct aliro_uwb_session *session)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:105

Tear down: destroy the CCC session, or free directly if there is none.

session
Session to close.
called by aliro_uwb_session_destroy, aliro_uwb_session_init, aliro_uwb_session_start, aliro_uwb_session_stop

Fenum aliro_uwb_err aliro_uwb_session_init(struct aliro_uwb_session *session)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:122

Initialize a session by creating and configuring a CCC Aliro responder, setting URSK, protocol version, antennas, and diagnostics, then starting the session. On any error, tears down the session and returns the mapped error code.

session
Session to initialize.
returns
ALIRO_UWB_ERR_NONE on success, ALIRO_UWB_ERR_INVALID_PARAMETER if session is NULL, or the mapped CCC error on failure.
calls session_close

Fenum aliro_uwb_err aliro_uwb_session_start(struct aliro_uwb_session *session)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:192

Start an active CCC session. On error, tears down the session and returns the mapped error code. the mapped CCC error on failure.

calls session_close

Fenum aliro_uwb_err aliro_uwb_session_stop(struct aliro_uwb_session *session)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:214

Stop an active CCC session, transitioning to SUSPENDED state. On error, tears down the session and returns the mapped error code.

session
Session to stop.
returns
ALIRO_UWB_ERR_NONE on success, ALIRO_UWB_ERR_INVALID_PARAMETER if session is NULL, or the mapped CCC error on failure.
calls session_close

Fstruct aliro_uwb_session *aliro_uwb_session_create(struct aliro_uwb_adapter *aliro_ctx, uint32_t session_id, aliro_uwb_session_cb_t callback, aliro_uwb_adapter_transmit_message_t transmit, void *user_data)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:234

Allocate an Aliro UWB session in the CREATED state, bound to an adapter and to the caller's transmit and event callbacks. No CCC session is started here.

Fvoid aliro_uwb_session_destroy(struct aliro_uwb_session *session)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:267

Destroy an Aliro UWB session, freeing the URSK and tearing down the underlying CCC session.

session
Session to destroy; no-op if NULL.
calls session_close

Fvoid aliro_uwb_session_message_free(struct aliro_uwb_message *message)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:281

Free a session message, delegating to the message-specific free function.

message
Message to free.

Fvoid aliro_uwb_session_event_free(struct aliro_uwb_session_event *event)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:289

Free a session event, releasing its wrapped CCC event if present.

Fenum aliro_uwb_err aliro_uwb_session_set_ursk(struct aliro_uwb_session *session, const uint8_t *ursk)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:309

Store a copy of the URSK (Unique Ranging Session Key) for later use during session initialization. Allocates a 16-byte buffer and returns ALIRO_UWB_ERR_INTERNAL on allocation failure.

session
Session that receives the copied URSK.
ursk
Source URSK bytes to copy.
returns
ALIRO_UWB_ERR_NONE on success, ALIRO_UWB_ERR_INVALID_PARAMETER if session or ursk is NULL, or ALIRO_UWB_ERR_INTERNAL on allocation failure.

Fenum aliro_uwb_err aliro_uwb_session_set_protocol_version(struct aliro_uwb_session *session, uint16_t selected_protocol_version)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:330

Store the protocol version selected by the reader for later use during session initialization.

session
Session that receives the selected protocol version.
selected_protocol_version
Protocol version chosen by the reader.
returns
ALIRO_UWB_ERR_NONE on success, or ALIRO_UWB_ERR_INVALID_PARAMETER if session is NULL.

Fenum aliro_uwb_err aliro_uwb_session_init_setup(struct aliro_uwb_session *session)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:348

Begin session setup by building and transmitting M1, transitioning from CREATED to M1_SENT state. Returns ALIRO_UWB_ERR_INVALID_STATE if not in CREATED state.

session
Session to begin setup on.
returns
ALIRO_UWB_ERR_NONE on success, ALIRO_UWB_ERR_INVALID_PARAMETER if session is NULL, ALIRO_UWB_ERR_INVALID_STATE if not in CREATED state, or ALIRO_UWB_ERR_INTERNAL if M1 could not be built.

Fenum aliro_uwb_err aliro_uwb_session_set_time_offset(struct aliro_uwb_session *session, int64_t time_offset)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:379

Store the time offset used to synchronize clocks between reader and device.

session
Session to update.
time_offset
Time offset in microseconds.
returns
ALIRO_UWB_ERR_NONE on success, ALIRO_UWB_ERR_INVALID_PARAMETER if session is NULL.

Fenum aliro_uwb_err aliro_uwb_session_message_handle(struct aliro_uwb_session *session, struct aliro_uwb_message *message)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:397

Validate and dispatch an incoming Aliro UWB message to the appropriate protocol handler.

session
Session that received the message.
message
Message to validate and process.
returns
ALIRO_UWB_ERR_NONE on success, ALIRO_UWB_ERR_INVALID_PARAMETER if session or message is NULL, ALIRO_UWB_ERR_MSG_MALFORMED if the message is shorter than the header or the payload length does not match, ALIRO_UWB_ERR_MESSAGE_UNSUPPORTED for an unrecognized protocol.

Fenum aliro_uwb_err aliro_uwb_session_suspend(struct aliro_uwb_session *session)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:439

Suspend an active ranging session by sending a suspend request.

session
Session to suspend.
returns
ALIRO_UWB_ERR_NONE on success, ALIRO_UWB_ERR_INVALID_PARAMETER if session is NULL, ALIRO_UWB_ERR_INVALID_STATE if there is no active CCC session or the session is not in the RANGING state, ALIRO_UWB_ERR_INTERNAL if the suspend request could not be built.

Fenum aliro_uwb_err aliro_uwb_session_forced_suspend(struct aliro_uwb_session *session)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:471

Forcibly stop the active CCC session, transitioning it to SUSPENDED without a request/response exchange.

session
Session to force-suspend.
returns
ALIRO_UWB_ERR_NONE on success, ALIRO_UWB_ERR_INVALID_PARAMETER if session is NULL, ALIRO_UWB_ERR_INVALID_STATE if no CCC session is active, otherwise the error translated from cherry_ccc_session_stop.

Fenum aliro_uwb_err aliro_uwb_session_resume(struct aliro_uwb_session *session)

modules/woz_uwb/src/aliro/aliro_uwb_session.c:493

Resume a suspended ranging session by building and transmitting a resume request. ALIRO_UWB_ERR_INVALID_STATE if there is no active CCC session or the session is not in the SUSPENDED state, ALIRO_UWB_ERR_INTERNAL if the resume request could not be built.