openaliro
Aliro reader: UWB/CCC core and ESP32-S3/C5/C6 port
Loading...
Searching...
No Matches
aliro_lab.h
1// Aliro Lab trace: structured "[ALAB]" lines at transaction phase boundaries,
2// parsed by tools/aliro_lab.py into a scored walk-up report. Ships in every Aliro
3// build (CONFIG_WOZ_ALIRO_LAB defaults y, like the sibling uwbdiag trace) but is
4// OFF at boot and toggled at runtime by the `lab on`/`lab off` console command, so
5// any firmware profiles on demand with no reflash. Set CONFIG_WOZ_ALIRO_LAB=n to
6// strip it from a hardened production image.
7/*
8 * Copyright (c) 2026 asxeem
9 * SPDX-License-Identifier: ISC
10 *
11 * aliro_lab — one line per event, `[ALAB] t=<us> ev=<name>[ <key>=<val>]`, with
12 * t from woz_uptime_us(). Emit only from the BLE-host or Matter task — never
13 * from the UWB RX/ISR path. UWB-side phase boundaries are latched by
14 * aliro_lat_mark() (a plain store) and printed later by aliro_lab_dump(), which
15 * runs once per walk-up from aliro_lat_report() (bolt) or the disconnect path,
16 * whichever comes first. Implemented in aliro_lat.c.
17 */
18#ifndef ALIRO_LAB_H
19#define ALIRO_LAB_H
20
21#include <stdbool.h>
22
23#if defined(ESP_PLATFORM)
24#include "sdkconfig.h" /* CONFIG_WOZ_ALIRO_LAB (Zephyr injects autoconf.h itself) */
25#endif
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#if defined(CONFIG_WOZ_ALIRO_LAB)
32
33/* Runtime gate: emitters are silent until enabled. OFF at boot; the console
34 * `lab on`/`lab off` command drives this so a lab-flashed image traces on
35 * demand. Set from the console task; a plain store is enough for a diagnostic. */
36void aliro_lab_set_enabled(bool on);
37bool aliro_lab_enabled(void);
38
39/* One trace line, stamped now (no-op while disabled). */
40void aliro_lab_ev(const char *ev);
41
42/* One trace line with a single integer attribute, stamped now (no-op while
43 * disabled). */
44void aliro_lab_evi(const char *ev, const char *key, long val);
45
46/* Same, with two integer attributes. Used where one number cannot identify the
47 * thing traced: a ranging SDU needs both its protocol and its message id, since
48 * the ids repeat across protocols (proto-2 id-1 is Initiate-Ranging-Session,
49 * proto-1 id-1 is M2). */
50void aliro_lab_evi2(const char *ev, const char *k1, long v1, const char *k2, long v2);
51
52/* Print a `ph.<name>` line for every latency phase stamped this walk-up, at the
53 * phase's own timestamp (no-op while disabled). One-shot until aliro_lat_begin()
54 * opens the next walk-up; call off the UWB path. */
55void aliro_lab_dump(void);
56
57#else
58
63static inline void aliro_lab_set_enabled(bool on)
64{
65 (void)on;
66}
67
72static inline bool aliro_lab_enabled(void)
73{
74 return false;
75}
76
81static inline void aliro_lab_ev(const char *ev)
82{
83 (void)ev;
84}
85
91static inline void aliro_lab_evi(const char *ev, const char *key, long val)
92{
93 (void)ev;
94 (void)key;
95 (void)val;
96}
97
102static inline void aliro_lab_evi2(const char *ev, const char *k1, long v1, const char *k2, long v2)
103{
104 (void)ev;
105 (void)k1;
106 (void)v1;
107 (void)k2;
108 (void)v2;
109}
110
114static inline void aliro_lab_dump(void)
115{
116}
117
118#endif /* CONFIG_WOZ_ALIRO_LAB */
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif /* ALIRO_LAB_H */