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

— device/initiator side of the UWB ranging-service setup codec: the inverse of the reader's M1/M3 builders + M2/M4 handlers in aliro_uwb_msg.c. More...

#include <stddef.h>
#include <stdint.h>
#include "aliro_uwb_msg_spec.h"
Include dependency graph for aliro_device_uwb.h:

Go to the source code of this file.

Data Structures

struct  aliro_dev_uwb_m1
 Ranging capabilities the reader offered in M1 (reader -> device). More...
 
struct  aliro_dev_uwb_m3
 Ranging parameters the reader committed in M3 (reader -> device). More...
 
struct  aliro_dev_uwb_m2_params
 Device selections carried in M2 (device -> reader). More...
 
struct  aliro_dev_uwb_m4_params
 Device selections carried in M4 (device -> reader). More...
 

Functions

int aliro_dev_uwb_parse_m1 (const uint8_t *msg, size_t len, struct aliro_dev_uwb_m1 *out)
 Parse an inbound M1 / M3 message ([proto][id][len_be16][attrs]) into the structs above.
 
int aliro_dev_uwb_parse_m3 (const uint8_t *msg, size_t len, struct aliro_dev_uwb_m3 *out)
 Parse an M3 UWB message: extract and validate ran multiplier, chaps per slot, number of responders, slots per round, sync code index bitmask, hopping configuration, and MAC mode.
 
void aliro_dev_uwb_select_m2 (const struct aliro_dev_uwb_m1 *m1, struct aliro_dev_uwb_m2_params *out)
 Pick M2 selections from a parsed M1: echo the reader's first config, pulse shape and channel, and default the remaining fields to values the reader accepts.
 
struct aliro_uwb_messagealiro_dev_uwb_build_m2 (const struct aliro_dev_uwb_m2_params *p)
 Build an M2 / M4 message.
 
struct aliro_uwb_messagealiro_dev_uwb_build_m4 (const struct aliro_dev_uwb_m4_params *p)
 Build an M4 UWB message from STS index, UWB time, hop mode key, and sync code index.
 

Detailed Description

— device/initiator side of the UWB ranging-service setup codec: the inverse of the reader's M1/M3 builders + M2/M4 handlers in aliro_uwb_msg.c.

The reader builds M1/M3 and consumes M2/M4; the device (phone/ fob) parses M1/M3 and builds M2/M4. Pure TLV, no crypto and no session state, so it is host-testable against the reader's own codec (loopback) and against the M2/M4 attribute sets the reader is proven to accept.

Copyright (c) 2026 asxeem SPDX-License-Identifier: ISC Provenance: clean-room; mirrors aliro_uwb_msg.c.

Function Documentation

◆ aliro_dev_uwb_build_m2()

struct aliro_uwb_message * aliro_dev_uwb_build_m2 ( const struct aliro_dev_uwb_m2_params p)

Build an M2 / M4 message.

Returns a heap-allocated message (free with aliro_uwb_msg_free), or NULL on allocation/encode failure.

◆ aliro_dev_uwb_parse_m1()

int aliro_dev_uwb_parse_m1 ( const uint8_t *  msg,
size_t  len,
struct aliro_dev_uwb_m1 out 
)

Parse an inbound M1 / M3 message ([proto][id][len_be16][attrs]) into the structs above.

Returns 0 on success, -1 on a header/attribute mismatch.

◆ aliro_dev_uwb_parse_m3()

int aliro_dev_uwb_parse_m3 ( const uint8_t *  msg,
size_t  len,
struct aliro_dev_uwb_m3 out 
)

Parse an M3 UWB message: extract and validate ran multiplier, chaps per slot, number of responders, slots per round, sync code index bitmask, hopping configuration, and MAC mode.

Return 0 on success or -1 if the message is malformed or required fields are missing.

◆ aliro_dev_uwb_select_m2()

void aliro_dev_uwb_select_m2 ( const struct aliro_dev_uwb_m1 m1,
struct aliro_dev_uwb_m2_params out 
)

Pick M2 selections from a parsed M1: echo the reader's first config, pulse shape and channel, and default the remaining fields to values the reader accepts.

A real device would consult its own capabilities here.