cherry_ccc_shim.c
cherry_ccc_* seam (Aliro responder) implemented over the lock-native…
Overview
cherry_ccc_* seam (Aliro responder) implemented over the lock-native FiRa MAC; maps each call onto woz_uwb_facade.
depends on woz_log.h cherry.h cherry_ccc.h cherry_session.h aliro_round_config.h woz_alloc.h woz_util.h woz_uwb_facade.h
API
Cstruct cherry
Opaque Cherry context holder.
core_cb- Core callback (never invoked: no UCI).
user_data- Client data from cherry_create().
Cstruct cherry_session
Base session object; first member of cherry_ccc_session for up-casting.
cb- CCC notification callback from create.
user_data- Client data (the aliro_uwb_session).
Cstruct cherry_ccc_session
CCC ranging session bound to FiRa MAC.
base- MUST be first member for up-casting.
config- Borrowed pointer to adapter's negotiated params, valid until destroy.
ursk- Provisioned-STS root key (16 bytes).
have_ursk- True if URSK has been stashed via set_ursk.
state- Last emitted session state (INIT, IDLE, ACTIVE, or DEINIT).
Fstatic inline struct cherry_ccc_session *to_ccc(struct cherry_session *base)
Up-cast a base session pointer (base is the first member).
cherry_session_destroy, cherry_session_start, cherry_session_stopFstatic void emit_status(struct cherry_ccc_session *s, enum cherry_ccc_session_state st)
Allocate and dispatch a SESSION_STATUS event to the CCC callback.
s- CCC session.
st- State to report (INIT, IDLE, ACTIVE, or DEINIT).
cherry_session_destroy, cherry_session_start, cherry_session_stopFstatic void emit_error(struct cherry_ccc_session *s, enum cherry_err err)
Allocate + dispatch a SESSION_ERROR event to the CCC callback.
cherry_session_startFstruct cherry *cherry_create(const char *device, cherry_core_cb_t core_cb, void *user_data)
Allocate and initialize a Cherry context with the given core callback and user data.
device- Device parameter (unused).
core_cb- Core callback (never invoked).
user_data- User data to store in the context.
- returns
- Cherry context pointer, or null if allocation fails.
Fvoid cherry_destroy_sync(struct cherry *ctx)
Deallocate a Cherry context; null input is safely ignored.
Fcherry_ccc_session_create_aliro_responder
Allocate and initialize an Aliro responder CCC session.
ctx- Cherry context (unused).
callback- CCC notification callback.
user_data- User context to pass to callback.
config- Session configuration (channel, session ID, STS index, timing, slot geometry).
- returns
- Session pointer, or null if callback is null, config is null, or allocation fails.
Fstruct cherry_session *cherry_ccc_session_to_base(struct cherry_ccc_session *session)
Cast a CCC session pointer to its embedded base session structure.
session- CCC session.
- returns
- Base session pointer, or null if session is null.
Fvoid *cherry_session_get_user_data(struct cherry_session *session)
Retrieve the user data pointer stored in the base session.
session- Base session.
- returns
- User data pointer, or null if session is null.
Fvoid cherry_session_destroy(struct cherry_session *session)
Stop the UWB radio, emit a DEINIT status event, and deallocate the session.
session- Base session; null or invalid input is safely ignored.
emit_status, to_cccFenum cherry_err cherry_session_start(struct cherry_session *session)
Start an Aliro UWB session by building a RangingConfiguration byte array from session config, calling woz_uwb_start_aliro, and emitting IDLE then ACTIVE status events.
session- Base session.
- returns
- CHERRY_ERR_INVALID_PARAMETER if session or config is null; CHERRY_ERR_SESSION_CONFIG if URSK is not set; CHERRY_ERR_SESSION_INIT if UWB start fails; otherwise CHERRY_ERR_NONE.
emit_error, emit_status, to_cccFenum cherry_err cherry_session_stop(struct cherry_session *session)
Stop the UWB radio and emit an IDLE status event.
session- Base session.
- returns
- CHERRY_ERR_INVALID_PARAMETER if session is null or invalid, otherwise CHERRY_ERR_NONE.
emit_status, to_cccFenum cherry_err cherry_ccc_session_set_ursk(struct cherry_ccc_session *session, const uint8_t *ursk)
Copy the URSK into the session and mark it as present.
session- CCC session.
ursk- 16-byte Unique Responder Session Key.
- returns
- CHERRY_ERR_INVALID_PARAMETER if session or ursk is null, otherwise CHERRY_ERR_NONE.
Fenum cherry_err cherry_ccc_session_set_protocol_version(struct cherry_ccc_session *session, uint16_t selected_protocol_version)
Validate that the session exists; selected protocol version is accepted but ignored.
session- CCC session.
selected_protocol_version- Protocol version (ignored).
- returns
- CHERRY_ERR_INVALID_PARAMETER if session is null, otherwise CHERRY_ERR_NONE.
Fenum cherry_err cherry_ccc_session_set_sts_index(struct cherry_ccc_session *session, uint32_t sts_index)
Store the STS index on the session config.
session- CCC session.
sts_index- STS index value.
- returns
- CHERRY_ERR_INVALID_PARAMETER if session or its config is null, otherwise CHERRY_ERR_NONE.
Fenum cherry_err cherry_ccc_session_set_initiation_time(struct cherry_ccc_session *session, uint64_t initiation_time_us)
Store the UWB initiation timestamp in microseconds on the session config.
session- CCC session.
initiation_time_us- Initiation timestamp in microseconds.
- returns
- CHERRY_ERR_INVALID_PARAMETER if session or its config is null, otherwise CHERRY_ERR_NONE.
Fenum cherry_err cherry_ccc_session_set_round2_antennas(struct cherry_ccc_session *session, uint8_t tx_antenna_set, uint8_t rx_antenna_set)
Validate that the session exists; TX and RX antenna set parameters are accepted but ignored.
session- CCC session.
tx_antenna_set- TX antenna set (ignored).
rx_antenna_set- RX antenna set (ignored).
- returns
- CHERRY_ERR_INVALID_PARAMETER if session is null, otherwise CHERRY_ERR_NONE.
Fenum cherry_err cherry_session_set_antennas(struct cherry_session *session, uint8_t tx_antenna_set, uint8_t rx_antenna_set)
Validate that the session exists; TX and RX antenna set parameters are accepted but ignored.
session- Base session.
tx_antenna_set- TX antenna set (ignored).
rx_antenna_set- RX antenna set (ignored).
- returns
- CHERRY_ERR_INVALID_PARAMETER if session is null, otherwise CHERRY_ERR_NONE.
Fenum cherry_err cherry_session_set_diagnostics(struct cherry_session *session, struct cherry_common_diag_cfg config, bool controlee_only)
Validate that the session exists; the diagnostics settings are accepted but ignored.
- returns
- CHERRY_ERR_INVALID_PARAMETER if session is null, otherwise CHERRY_ERR_NONE.
Fvoid cherry_ccc_event_free(struct cherry_ccc_event *event)
Free a CCC event and its payload; null input is safely ignored.