20#define CCC_PRE_POLL_LEN 13
22#define CCC_FINAL_DATA_HDR_LEN 18
24#define CCC_RESPONDER_LEN 7
26#define CCC_MAX_RESPONDERS 10
28#define CCC_MSG_ID_PRE_POLL 0x01u
30#define CCC_MSG_ID_FINAL_DATA 0x02u
138 enum ccc_slot slot, uint8_t responder);
165#define CCC_STS_INDEX_MAX 0x7FFFFFFFu
UWB ranging key schedule + SP0 frame crypto (CONFIG_WOZ_ALIRO).
#define CCC_KEYSOURCE_LEN
KeySource length, bytes (KeySourceHigh || KeySourceLow).
Definition ccc_kdf.h:38
uint32_t ccc_slot_sts_index(const struct ccc_ran_params *p, uint32_t block, uint16_t round, enum ccc_slot slot, uint8_t responder)
STS index for one slot of a ranging round (uint32 wraps mod 2^32).
Definition ccc_mac.c:288
int ccc_final_data_pack(const struct ccc_final_data *f, uint8_t *out, size_t cap, size_t *len)
Pack a Final_Data payload little-endian.
Definition ccc_mac.c:177
int ccc_responder_ds_twr(const struct ccc_final_data *fd, uint8_t responder, uint32_t t_reply1, uint32_t t_round2, struct ccc_ds_twr *out)
Assemble the DS-TWR intervals at the responder from a received Final_Data.
Definition ccc_mac.c:339
#define CCC_PRE_POLL_LEN
Pre-POLL MAC payload length, bytes.
Definition ccc_mac.h:20
bool ccc_ursk_exhausted(const struct ccc_ran_params *p, uint32_t block)
Whether the current URSK is exhausted for a ranging block (true once its highest STS index would exce...
Definition ccc_mac.c:355
#define CCC_MAX_RESPONDERS
Max responders in one Final_Data (127-byte payload cap).
Definition ccc_mac.h:26
int ccc_build_mhr(const struct ccc_mhr_fields *f, uint8_t out[CCC_MHR_LEN])
Build the 23-byte SP0 MHR (little-endian on the wire).
Definition ccc_mac.c:82
uint32_t ccc_ds_twr_tof(const struct ccc_ds_twr *t)
DS-TWR one-way time-of-flight in timestamp ticks (0 if the denominator is 0).
Definition ccc_mac.c:327
int ccc_final_data_parse(const uint8_t *in, size_t len, struct ccc_final_data *f)
Parse a Final_Data payload (-EINVAL if length is inconsistent with num_responders).
Definition ccc_mac.c:215
uint16_t ccc_block_round(const struct ccc_ran_params *p, uint32_t block)
The ranging round a block uses (block 0 uses round 0; continuous hopping uses S(i) for i>=1).
Definition ccc_mac.c:269
struct ccc_hop_decision ccc_initiator_next_hop(const struct ccc_ran_params *p, uint32_t block)
The initiator's hop decision for the block after block, written into its Final_Data.
Definition ccc_mac.c:309
uint16_t ccc_hop_round_index(uint32_t block_index, uint32_t hop_key_rw, uint32_t n_round)
Default hopping round index S(i) in [0, n_round) for a ranging block, keyed by HOP_Key_RW.
Definition ccc_mac.c:18
int ccc_pre_poll_pack(const struct ccc_pre_poll *p, uint8_t out[CCC_PRE_POLL_LEN])
Pack a Pre-POLL payload little-endian.
Definition ccc_mac.c:134
int ccc_pre_poll_parse(const uint8_t in[CCC_PRE_POLL_LEN], struct ccc_pre_poll *p)
Parse a 13-byte Pre-POLL payload.
Definition ccc_mac.c:154
ccc_hop_mode
Hopping mode.
Definition ccc_mac.h:99
@ CCC_HOP_CONTINUOUS
Continuous hopping: block i uses round S(i).
Definition ccc_mac.h:101
@ CCC_HOP_NONE
No hopping: every block uses ranging round 0.
Definition ccc_mac.h:100
int ccc_parse_mhr(const uint8_t in[CCC_MHR_LEN], struct ccc_mhr_fields *f)
Parse and validate a 23-byte SP0 MHR, extracting the variable fields (-EINVAL on mismatch).
Definition ccc_mac.c:110
#define CCC_MHR_LEN
SP0 MHR length, bytes.
Definition ccc_mac.h:18
ccc_slot
Slot role within a ranging round.
Definition ccc_mac.h:105
@ CCC_SLOT_FINAL_DATA
SP0 data packet, initiator.
Definition ccc_mac.h:110
@ CCC_SLOT_PRE_POLL
Slot 0 — SP0 data packet, initiator.
Definition ccc_mac.h:106
@ CCC_SLOT_FINAL
SP3 RFRAME, initiator.
Definition ccc_mac.h:109
@ CCC_SLOT_POLL
Slot 1 — SP3 RFRAME, initiator.
Definition ccc_mac.h:107
@ CCC_SLOT_RESPONSE
Slots 2..1+N — SP3 RFRAME, responder l.
Definition ccc_mac.h:108
The four DS-TWR intervals, in ranging-timestamp ticks (uint32, wrap mod 2^32).
Definition ccc_mac.h:148
uint32_t t_reply1
Responder POLL rx → RESPONSE tx (t3 − t2).
Definition ccc_mac.h:150
uint32_t t_round2
Responder RESPONSE tx → FINAL rx (t6 − t3).
Definition ccc_mac.h:151
uint32_t t_reply2
Initiator RESPONSE rx → FINAL tx (t5 − t4).
Definition ccc_mac.h:152
uint32_t t_round1
Initiator POLL tx → RESPONSE rx (t4 − t1).
Definition ccc_mac.h:149
Final_Data message parameters.
Definition ccc_mac.h:79
uint32_t final_sts_index
STS index of the preceding FINAL message.
Definition ccc_mac.h:84
uint8_t num_responders
Responder records that follow (≤ CCC_MAX_RESPONDERS).
Definition ccc_mac.h:86
uint32_t ranging_ts_final_tx
POLL→Final transmit time difference.
Definition ccc_mac.h:85
uint16_t ranging_block
Index of the current ranging block.
Definition ccc_mac.h:81
uint16_t round_index
Ranging round for the next ranging block.
Definition ccc_mac.h:83
uint8_t hop_flag
Hop flag for the next ranging block.
Definition ccc_mac.h:82
uint32_t uwb_session_id
ID of the UWB ranging session.
Definition ccc_mac.h:80
The initiator's next-block hop decision, carried in Final_Data.
Definition ccc_mac.h:128
uint8_t hop_flag
Hop_Flag for the next ranging block.
Definition ccc_mac.h:129
uint16_t round_index
Round_Index for the next ranging block.
Definition ccc_mac.h:130
The per-frame-variable fields of an SP0 MHR (fixed fields are built in by ccc_build_mhr).
Definition ccc_mac.h:35
uint8_t payload_len
Vendor Info byte 2 (MAC payload length).
Definition ccc_mac.h:40
uint8_t msg_id
Vendor Info byte 1 (CCC_MSG_ID_*).
Definition ccc_mac.h:39
uint8_t key_source[CCC_KEYSOURCE_LEN]
Aux Security Header Key Source.
Definition ccc_mac.h:38
uint32_t frame_counter
Aux Security Header frame counter.
Definition ccc_mac.h:37
uint16_t dest_short_addr
Destination Short Address.
Definition ccc_mac.h:36
Pre-POLL request message parameters.
Definition ccc_mac.h:52
uint16_t ranging_block
Session's index of the current ranging block.
Definition ccc_mac.h:55
uint32_t uwb_session_id
ID of the UWB ranging session.
Definition ccc_mac.h:53
uint8_t hop_flag
Hop flag for the current ranging block.
Definition ccc_mac.h:56
uint32_t poll_sts_index
STS index of the succeeding POLL message.
Definition ccc_mac.h:54
uint16_t round_index
Ranging round index for the current block.
Definition ccc_mac.h:57
Per-session ranging schedule parameters (negotiated in setup).
Definition ccc_mac.h:116
uint32_t sts_index0
STS_Index0 — ranging round 0 of block 0.
Definition ccc_mac.h:117
uint32_t hop_key_rw
HOP_Key_RW (continuous hopping).
Definition ccc_mac.h:121
uint16_t n_slot_per_round
N_Slot_per_Round.
Definition ccc_mac.h:118
enum ccc_hop_mode hop_mode
Hopping mode.
Definition ccc_mac.h:122
uint8_t n_responder
N_Responder (1..CCC_MAX_RESPONDERS).
Definition ccc_mac.h:120
uint16_t n_round
N_Round — rounds per block (> 0).
Definition ccc_mac.h:119
One responder's timestamp record in a Final_Data message.
Definition ccc_mac.h:69
uint32_t timestamp
POLL→RESPONSE time difference at the initiator.
Definition ccc_mac.h:71
uint8_t ranging_status
Per-responder ranging status.
Definition ccc_mac.h:73
uint8_t timestamp_uncertainty
Ranging timestamp uncertainty.
Definition ccc_mac.h:72
uint8_t responder_index
Index of the responder this record refers to.
Definition ccc_mac.h:70