Skip to content

nrf52: turn off BLE connection LED before SYSTEMOFF 🤖🤖#2662

Open
disq wants to merge 1 commit into
meshcore-dev:devfrom
disq:nrf52-ble-led-off-sysoff
Open

nrf52: turn off BLE connection LED before SYSTEMOFF 🤖🤖#2662
disq wants to merge 1 commit into
meshcore-dev:devfrom
disq:nrf52-ble-led-off-sysoff

Conversation

@disq
Copy link
Copy Markdown

@disq disq commented Jun 1, 2026

Problem

On nRF52 boards, the BLE connection LED stays lit after entering hibernation (SYSTEMOFF / deep sleep).

Bluefruit's autoConnLed defaults on and drives LED_CONN (the disable is commented out in SerialBLEInterface.cpp). nRF52 SYSTEMOFF only halts the core and leaves GPIO outputs latched in their last drive state, while enterSystemOff() never turns the LED off or stops BLE. So the LED stays on through deep sleep — solid when a companion app is connected, or caught mid-blink while advertising.

Fix

In the shared NRF52Board::enterSystemOff() funnel, before entering SYSTEMOFF:

  • disable autoConnLed and stop advertising so BLE no longer drives the pin,
  • pull LED_CONN low with the polarity-aware ledOff() macro (respects each variant's LED_STATE_ON — boards differ: rak3401 is active-high, XIAO active-low).

The Bluefruit calls are gated on the SoftDevice being enabled, so the early low-voltage / boot-protect path (which runs before Bluefruit.begin()) is safe; ledOff() always runs. Awake behavior is unchanged — the LED still indicates BLE status during normal operation.

This is a general nRF52 issue, not board-specific. Fixing it in the shared funnel covers every board that hibernates through enterSystemOff() in one place: rak3401, rak4631, xiao_nrf52.

Not covered

promicro and rak_wismesh_tag call sd_power_system_off() directly in their own powerOff() rather than routing through enterSystemOff(), so they are not fixed by this change. Left as a follow-up (either the same LED-off prep added to those paths, or routing them through enterSystemOff()).

Testing

Builds clean for RAK_3401_companion_radio_ble, RAK_4631_companion_radio_ble, and Xiao_nrf52_companion_radio_ble (covers both LED polarities).

🤖 Generated with Claude Code

Bluefruit's autoConnLed (on by default) drives LED_CONN. nRF52 SYSTEMOFF
only halts the core and leaves GPIO outputs latched in their last drive
state, so the BLE LED stayed lit through hibernation -- solid when a
companion app was connected, or caught mid-blink while advertising.

In the shared enterSystemOff() funnel, disable autoConnLed and stop
advertising so BLE no longer drives the pin, then pull LED_CONN low with
the polarity-aware ledOff() macro (respects each variant's LED_STATE_ON).
This covers every board that hibernates through enterSystemOff() --
rak3401, rak4631 and xiao_nrf52 -- in one place. The Bluefruit calls are
gated on the SoftDevice being enabled so the early low-voltage /
boot-protect path (before Bluefruit.begin()) is safe; ledOff() always runs.
Awake behavior is unchanged -- the LED still indicates BLE status.

Note: promicro and rak_wismesh_tag call sd_power_system_off() directly
rather than via enterSystemOff(), so they are not covered by this change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@disq disq changed the title nrf52: turn off BLE connection LED before SYSTEMOFF nrf52: turn off BLE connection LED before SYSTEMOFF 🤖🤖 Jun 1, 2026
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