From e217b6d6f749a1b6d71a8f7ebda5f7f39d31d5ed Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Tue, 4 Aug 2026 13:48:07 +0200 Subject: [PATCH] fix(repeater): advertise the node's real name over BLE; harden the UF2 flasher BLE name: Bluefruit.setName() was given BLE_DEVICE_NAME, which defaults to the build-time ADVERT_NAME. That only ever seeds a fresh install, so once the whole test fleet runs one image every board advertises the same string regardless of `set name`, and a BLE scan cannot tell them apart. Four boards were advertising "bench-board" simultaneously here -- including the one with the dead radio, which is precisely the board you least want to mistake for a working one. Now it advertises the prefs name, with the build constant as the fallback for a node that has never been named. Prefs are loaded by the_mesh.begin() well before Bluefruit.begin(), so the name is available. xiao_uf2_flash.sh, after four rounds of it being not quite foolproof enough: - takes an explicit target (serial or fleet number 0..4) and refuses to write to any other board; the earlier version reported x4's port after flashing x3, which reads exactly like a successful flash of the wrong board - rejects a file that is not a UF2 (a .hex or .zip dropped on the drive is ignored by the bootloader and looks like success) - refuses an image older than firmware.elf, and demands the version stamp - resolves drives through sysfs by USB serial, never by label -- every drive is XIAO-SENSE, numbered in plug order - retries the mount (the automounter loses the race with a fresh drive) and the version read-back (the port enumerates seconds before the firmware answers on it). A check that cries wolf is worse than no check. - proves the flash by reading `ver` off the board and comparing it to the image, instead of trusting that some XIAO came back on USB Co-Authored-By: Claude Opus 5 --- examples/simple_repeater/main.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 32e8a4af..080253eb 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -651,7 +651,18 @@ void setup() { // the library ever sets the CONN role, so an established link runs at the // SoftDevice default 0 dBm. See RPT_BLE_CONN_TX_POWER / `blepwr` for that half. Bluefruit.setTxPower(8); - Bluefruit.setName(BLE_DEVICE_NAME); + // CUSTOM (TeTeHacko): advertise the node's ACTUAL name, not the build-time + // constant. BLE_DEVICE_NAME defaults to ADVERT_NAME, which only ever seeds a + // fresh install -- so once several boards share one image, they all advertise + // the same string no matter what `set name` says, and a BLE scan cannot tell + // them apart. Four boards here advertised "bench-board" at once, including the + // one with a dead radio. The prefs name is the one that was deliberately set, + // so that is the one to broadcast; the build constant stays the fallback for a + // node that has never been named. + { + const char* nm = the_mesh.getNodePrefs()->node_name; + Bluefruit.setName((nm && nm[0]) ? nm : BLE_DEVICE_NAME); + } Bluefruit.Security.setPIN(_MC_STR(BLE_PIN_CODE)); // widen the BLE connection params so the busy LoRa loop can't trip the // (default 2 s) supervision timeout -> no more reconnect churn. PPCP is