nrf52: turn off BLE connection LED before SYSTEMOFF 🤖🤖#2662
Open
disq wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On nRF52 boards, the BLE connection LED stays lit after entering hibernation (SYSTEMOFF / deep sleep).
Bluefruit's
autoConnLeddefaults on and drivesLED_CONN(the disable is commented out inSerialBLEInterface.cpp). nRF52 SYSTEMOFF only halts the core and leaves GPIO outputs latched in their last drive state, whileenterSystemOff()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:autoConnLedand stop advertising so BLE no longer drives the pin,LED_CONNlow with the polarity-awareledOff()macro (respects each variant'sLED_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
promicroandrak_wismesh_tagcallsd_power_system_off()directly in their ownpowerOff()rather than routing throughenterSystemOff(), 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 throughenterSystemOff()).Testing
Builds clean for
RAK_3401_companion_radio_ble,RAK_4631_companion_radio_ble, andXiao_nrf52_companion_radio_ble(covers both LED polarities).🤖 Generated with Claude Code