# FindFamily UWB tracker — nRF52833 (Qorvo DWM3001C module) # PSA crypto needs a few KB of stack, and the main loop is where the epoch id is # derived and the beacon started (both moved off the Bluetooth RX thread, whose stack # is far too small for either — doing them inline in a GATT callback faults). CONFIG_MAIN_STACK_SIZE=4096 # --- Bluetooth ------------------------------------------------------------ CONFIG_BT=y CONFIG_BT_PERIPHERAL=y CONFIG_BT_DEVICE_NAME="FF Tracker" CONFIG_BT_DEVICE_APPEARANCE=0 # Two connection slots, not one. The switch to beacon mode happens while the binding # phone is still attached, and starting a *connectable* advertisement needs a free slot — # with a single slot it fails with -ENOMEM and the tracker ends up advertising nothing. CONFIG_BT_MAX_CONN=2 # The crowd-finding beacon is [16B epochId][1B battery] of service data under a # 128-bit UUID = 35 bytes on air, past the 31-byte legacy limit, so it has to be an # extended advertisement. Pairing mode stays legacy (21 bytes) so the phone can find # it with default scan settings. CONFIG_BT_EXT_ADV=y # Three advertising sets: the legacy pairing set, the extended beacon (data, not # connectable), and a connectable set that runs alongside the beacon so the owner can write # UWB session params while crowd-finding. See beacon_param in src/tracker_ble.c for why # connectability cannot live on the beacon set itself. CONFIG_BT_EXT_ADV_MAX_ADV_SET=3 CONFIG_BT_CTLR_ADV_EXT=y CONFIG_BT_GATT_DYNAMIC_DB=y # A client on the default 23-byte ATT MTU sends the 48-byte provisioning blob as a long # write in ~20-byte chunks, so there must be room to queue at least three of them. CONFIG_BT_ATT_PREPARE_COUNT=6 # Must fit the 48-byte provisioning write in a single ATT operation when the client does # negotiate a larger MTU (the app asks for one). CONFIG_BT_BUF_ACL_RX_SIZE=69 CONFIG_BT_L2CAP_TX_MTU=65 # --- Crypto (PSA / nrf_security) ----------------------------------------- # Epoch ids must be byte-identical to TrackerProtocol.epochId on the phone and # tracker_epoch_id on the server, so use the same primitives: HMAC-SHA256 and # HKDF-SHA256. CONFIG_NRF_SECURITY is deliberately not set: it is def_bool y once # PSA_CRYPTO selects the Nordic provider, and assigning it directly is an error. CONFIG_PSA_CRYPTO=y CONFIG_PSA_WANT_ALG_SHA_256=y CONFIG_PSA_WANT_ALG_HMAC=y CONFIG_PSA_WANT_ALG_HKDF=y CONFIG_PSA_WANT_KEY_TYPE_HMAC=y CONFIG_PSA_WANT_KEY_TYPE_DERIVE=y CONFIG_HEAP_MEM_POOL_SIZE=4096 # --- Persistence --------------------------------------------------------- # The provisioning blob and the time base have to survive a reset, or the tracker # beacons ids no owner is looking for. CONFIG_NVS=y CONFIG_FLASH=y CONFIG_FLASH_MAP=y CONFIG_FLASH_PAGE_LAYOUT=y CONFIG_SETTINGS=y CONFIG_SETTINGS_NVS=y # --- Board I/O ----------------------------------------------------------- CONFIG_GPIO=y # Hardware watchdog, fed by the main loop. A hung tracker advertises nothing, so a hang # takes crowd-finding down with it and stays down until someone resets the board by hand. # This turns that into a few seconds of downtime. See watchdog_init() in src/main.c. CONFIG_WATCHDOG=y # --- Logging over the on-board J-Link CDC UART --------------------------- CONFIG_LOG=y CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y CONFIG_LOG_MODE_DEFERRED=y CONFIG_LOG_BUFFER_SIZE=4096 # Deferred logging processes every message on one thread, created at # K_LOWEST_APPLICATION_THREAD_PRIO (14 here) unless told otherwise — below both UWB threads, # so a busy UWB thread erased the record of what it was doing. Raising that thread above them # is the fix; CONFIG_LOG_MODE_IMMEDIATE is not. Immediate mode "is processed in the context of # the call" (Kconfig.mode), i.e. a LOG_INF from the Bluetooth RX thread sits in uart_poll_out # for milliseconds per line, which is what made every GATT connection fail with Android # status 133. A separate thread cannot do that to it: the RX thread is cooperative # (K_PRIO_COOP(CONFIG_BT_RX_PRIO), hci_core.c) so no preemptible priority preempts it. # # 3 rather than something higher: above both UWB threads (6 and 7) and level with the Qorvo # MAC's NORMAL band, which timeslicing then shares with rather than starving. CONFIG_LOG_PROCESS_THREAD_CUSTOM_PRIORITY=y CONFIG_LOG_PROCESS_THREAD_PRIORITY=3 # CONFIG_LOG_PRINTK is deliberately left at its default (y), so printk() stays inside the # logging subsystem. Turning it off would make the ff_uwb_start() markers synchronous, but # it also sends them to *the console* — the CDC UART, the path that drops lines (see below). # The lossless path is CONFIG_LOG_BACKEND_RTT, and a log backend only ever sees LOG_*, never # printk. Bring-up markers therefore go through LOG_INF, which reaches both backends. # Also log over SEGGER RTT. The CDC UART path loses lines — a capture that should have held # ~120 once-per-second beacon messages held 46 — which is bad enough to have produced # contradictory evidence while debugging (a GATT write the phone reported as successful and # the firmware appeared never to receive). RTT goes over the debug probe and doesn't drop. CONFIG_USE_SEGGER_RTT=y CONFIG_LOG_BACKEND_RTT=y CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=4096 CONFIG_REBOOT=y