Two diagnostic levers for the BLE/LoRa coexistence work, plus a correction to
what the existing tx power call actually does.
Bluefruit.setTxPower(8) is ADVERTISING power only. Bluefruit stores the value
and BLEAdvertising::start() hands it to sd_ble_gap_tx_power_set() with
BLE_GAP_TX_POWER_ROLE_ADV; nothing in the library ever sets the CONN role, so an
established link runs at the SoftDevice default of 0 dBm. The +8 buys discovery
range and nothing else. Confirmed on hardware: `blepwr` reports
"conn tx: 0 dBm, adv tx: 8 dBm".
- RPT_BLE_CONN_TX_POWER (default 0 = unchanged behaviour), applied per
connection on every 'secured' since the handle is new each time.
- `blepwr [dBm]` sets it at runtime over serial, the BLE console or the mesh
admin CLI. Runtime rather than a build flag because a dose-response sweep
needs many points and reflashing the XIAO costs a physical UF2 dance.
- Auto-revert after 5 min (`blepwr <p> hold` opts out). Without it the command
locks you out of the console you would need to undo it: the value is
re-applied on every 'secured', at -20 dBm the node's replies stop arriving and
at -40 dBm a connection cannot be established at all. Hit this on the bench;
recovery was over USB, and on the mast the only way back would be `reboot`
over the mesh admin CLI.
- `bleconn` reports the connection parameters actually in force. bleOnSecured()
only REQUESTS 15-30/60-80 ms and the central may refuse, so without reading
them back "the pre-fix interval showed no loss either" cannot be told apart
from "the pre-fix interval was never in force". Latched once a second from
loop() so it can be read over USB after the central is gone -- reading it over
the BLE console while connected would collide on the shared command[160].
Measured with these: at a verified 22.50 ms interval, sweeping the connection
tx power from 0 to -20 dBm (RSSI -67..-87 at the central, covering the whole
-75..-90 window the mast sits in) produced zero lost DIRECT forwards, with
tx_timeout and tx_start_fail at zero in every cell.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
bleWriteAll used to spin-retry with delay(3) when the SoftDevice
notification queue was full, stalling loop() up to ~0.9 s per call
while a client streamed the console (rxlog/pktlog drains). That is
long enough to disturb LoRa RX/TX timing on the relay path.
Replace with a 4 KB ring buffer: bleWriteAll only enqueues, and
bleTxPump() (each loop pass) hands the SoftDevice as much as it will
take right now — zero waiting. Overflow truncates the newest bytes;
a torn page loses its 'E,' trailer so the bridge re-requests the
same cursor.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Fewer SoftDevice connection events = fewer LoRa TX collisions (the
measured driver of the direct-forward loss); the Dispatcher TX retry
covers the residue. Bigger pktfeed ring buys margin for the bridge's
new connect->drain->disconnect duty cycle (~3-4 min between drains).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The BLE bridge drain was throttled by three multiplied costs: 150 B pages
(~3 rxlog records), 20 B NUS notification chunks, and the bridge waiting for
line silence per page. This fixes the firmware half:
- handleCommand() takes an explicit reply_max (default 150). The local console
(USB/BLE) passes ~1000 B -> ~20 rxlog records / ~7 nodes lines per round
trip; the mesh admin CLI keeps 150 so its reply still fits one LoRa packet.
Explicit parameter on purpose: a forged sender_timestamp==0 from the mesh
path must never be able to grow the reply past its 166 B buffer.
- bleWriteAll() chunks by negotiated MTU (247 -> 244 B) instead of fixed 20 B.
- Tables sized from channel physics instead of last week's traffic:
RXLOG_SIZE 512 = ~2 min of a saturated SF8/62.5k channel (~2-4 frames/s),
MAX_HEARD_NODES 128 > distinct nodes heard per neighbour advert period
(48 filled in <2 h and churned out real 0-hop neighbours).
- Page-sort scratch arrays moved off the loop-task stack into BSS.
RAM 17.7% -> 25.3% (59.6 KB / 235 KB). Flashed via BLE DFU 2026-07-15.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
btmon shows the disconnects are HCI reason 0x3E (Connection Failed to be
Established / lost sync), not supervision timeout -- so widening the timeout
didn't help. The mast link is weak (RSSI -75..-90) and the node is busy with
LoRa; with slave latency 4 the peripheral may skip connection events, so the
central loses sync and reports 0x3E. Respond on every event (latency 0) to
maximise sync on a weak/busy link.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
6 s cut the reconnect churn from every 15-30 s to every ~60 s but didn't
eliminate it: under the bridge's real polling load the node shows a
periodic multi-second stall (advert TX airtime / SoftDevice-LoRa
coexistence) that occasionally exceeds 6 s. Widen the supervision timeout
to 16 s so those stalls are tolerated; a genuine freeze is still caught by
the 20 s hardware watchdog (16 s < 20 s).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The BLE console link dropped every ~15-30 s and the bridge kept
reconnecting. Root cause: Bluefruit's default supervision timeout is only
2 s, and this repeater relays heavy LoRa flood traffic, so main-loop /
radio coexistence stalls past 2 s and the central tears down the link.
Mirror the companion's proven approach (explicit sd_ble_gap_conn_param_update
on 'secured', since some centrals ignore the advertised PPCP) but widen the
supervision timeout to 6 s (a repeater is far busier than a client), with a
15-30 ms interval and slave latency 4. PPCP is also set before advertising.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Repeater can be queried over BLE Nordic-UART (advert/neighbours/stats) without USB. Fix SoftDevice-protected TEMP peripheral access (sd_temp_get) that crashed BLE repeater telemetry, add USB-connected detection to ArduinoSerialInterface, and adjust the nRF52 ldscript/extra FS.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Framework for upcoming variant-specific PRs that add LED feedback during boot. The hook gives users visual cues that the device is busy and
shouldn't be interacted with until startup completes.
This commit refactors the serial bridge functionality out of the `simple_repeater` example and into a more reusable, object-oriented structure.
An `AbstractBridge` interface has been introduced, along with a concrete `SerialBridge` implementation. This encapsulates all the logic for packet framing, checksum calculation, and serial communication, cleaning up the main example file significantly.
The `simple_repeater` example now instantiates and uses the `SerialBridge` class, resulting in better separation of concerns and improved code organization.