Skip to content

bt: add AT+STATUS runtime diagnostics and fix the peripheral interval range - #6

Merged
Amigache merged 2 commits into
EdgeTX:developfrom
Amigache:feat/diagnostics
Nov 26, 2026
Merged

Amigache merged 2 commits into
EdgeTX:developfrom
Amigache:feat/diagnostics

Conversation

@Amigache

Copy link
Copy Markdown
Collaborator

bt: add AT+STATUS runtime diagnostics and fix the peripheral interval range

Summary

Two pieces of the anchor-port work that are worth having in develop, without
bringing the rest of that branch:

  1. Fix: in the peripheral (telemetry) role the connection-interval request
    was built with min_int and max_int swapped, so it carried min > max and
    no central can apply it. Both are set the right way round now.
  2. Feature: AT+STATUS, a project extension that dumps the runtime counters
    of the central (trainer master) data path.

Why

The diagnostics come from a real support case: a radio reported "trainer signal
lost / recovered" in a loop while the BLE link was fine (the tracker's LED
stayed solid). With AT+STATUS it took one command to show that the module was
receiving and forwarding every frame, and that the frames were being dropped on
the radio side. Without it, the only signal is "the trainer doesn't work".

Output

OK+STATUS rx=3789 malformed=0 uartPkts=3789 uartBytes=64413 wrMaxUs=107
           rxToUartMaxUs=115 rxToUartAvgUs=43 gapMaxMs=29 gaps100=0
Field Meaning
rx framed notifications forwarded
malformed notifications dropped (empty or not 0x7E-framed)
uartPkts / uartBytes frames and bytes written to the radio UART
wrMaxUs worst UART write duration (µs)
rxToUartMaxUs / rxToUartAvgUs BLE -> UART latency, worst / average (µs)
gapMaxMs / gaps100 worst gap between notifications, and gaps over 100 ms

Implementation notes

  • Counters are written by the BLE task and only read by the AT+STATUS dump, so
    no lock is added to the data path; torn reads are acceptable for a dump.
  • Like every AT command, AT+STATUS pauses the trainer passthrough while it is
    parsed; the handler restores it immediately (the command does not touch the
    link). tools/at_bench.py checks that the stream survives it.
  • No behaviour change when the command is not used.

Testing

  • pio test -e native: 23/23.
  • Clean builds: C3SuperMini, C3SuperMini_nimble, ESP32_DEV38P,
    ESP32_DEV38P_nimble.
  • ESP32-C3 SuperMini on both BLE hosts, with a BLE headtracker streaming:
    • tools/at_bench.py: 18/18 (the bench now covers AT+STATUS).
    • Stream: 72.8 frames/s (NimBLE) / 72.7 frames/s (Bluedroid), max gap 48/49 ms,
      no gaps over 100 ms, and the rate is unchanged right after AT+STATUS.
    • Latency: 43 µs average (NimBLE) / 86 µs (Bluedroid).
    • malformed=0, uartPkts == rx, gaps100=0.
  • doc/BENCH.md and README.md updated (command table, check count, validation
    matrix).

Notes

The rest of anchor-port (bounded BLE->UART queue, 7.5 ms/2M link tuning,
ROLE0 auto-detection and the CRSF viewer compatibility) stays in that branch:
the measurements show no benefit over the direct write on the current hardware,
and the ROLE0 auto-detection changes peripheral behaviour by default.

The peripheral (telemetry) role asked for the connection interval with min_int and max_int swapped, so the update carried min > max and no central can apply it. Set the range the right way round.
A trainer link can look broken while the module is working: the counters make the difference visible from the radio side. AT+STATUS reports the framed notifications forwarded, malformed payloads, UART packets/bytes, the worst UART write and BLE->UART latency (average and worst) and the notification gap statistics.
@Amigache
Amigache merged commit 5c575fb into EdgeTX:develop Nov 26, 2026
2 checks passed
@Amigache
Amigache deleted the feat/diagnostics branch November 26, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant