Skip to content

Preferences for BLE and status LEDs#1934

Open
andyshinn wants to merge 6 commits intomeshcore-dev:mainfrom
andyshinn:ashinn/configurable-leds
Open

Preferences for BLE and status LEDs#1934
andyshinn wants to merge 6 commits intomeshcore-dev:mainfrom
andyshinn:ashinn/configurable-leds

Conversation

@andyshinn
Copy link

@andyshinn andyshinn commented Mar 6, 2026

This adds some settings to control the BLE and status LEDs:

  • led.ble

    • 0: Enables the normal behavior of blinking when disconnected from BLE and solid when connected to BLE.
    • 1: Blinks BLE LED only when disconnected from BLE.
    • 2: Turns on the BLE LED solid when connected but doesn't blink when disconnected.
    • 3: Disables the BLE LED.
  • led.status:

    • 0: Existing behavior to enable the status LED blinking.
    • 1: Disables the status LED.

For the BLE LED to work it required a patch to the upstream Bluefruit SDK so I added that here as well.

Will need to be added in downstream clients. Now done as custom vars so we already get them in clients. Can also be tested in CLI Rescue with set led.status # and set led.ble #

Possibly related to #1214.

Copilot AI review requested due to automatic review settings March 6, 2026 01:36
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds user-configurable preferences to control BLE connection LED behavior and status LED blinking, including an upstream Bluefruit SDK patch to ensure autoConnLed(false) reliably prevents SDK-driven LED toggling.

Changes:

  • Introduces led.ble and led.status persisted preferences (plus CLI Rescue setters) in the companion_radio example.
  • Extends NRF52 SerialBLEInterface to accept a BLE LED mode and to manage the BLE LED state in connect/secure/disconnect flows.
  • Adds UI task logic to disable status LED blinking and to implement “blink only when disconnected” for BLE LED in the companion UI.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/helpers/nrf52/SerialBLEInterface.h Adds a stored BLE LED mode and extends begin() signature to accept it.
src/helpers/nrf52/SerialBLEInterface.cpp Implements BLE LED mode behavior and disables SDK auto LED handling for non-default modes.
examples/companion_radio/ui-orig/UITask.h Adds BLE LED pin resolution and declares a BLE LED handler.
examples/companion_radio/ui-orig/UITask.cpp Disables status LED blinking via pref; adds disconnected-only BLE LED blink handler.
examples/companion_radio/ui-new/UITask.h Adds BLE LED pin resolution and per-instance BLE blink state.
examples/companion_radio/ui-new/UITask.cpp Disables status LED blinking via pref; adds disconnected-only BLE LED blink handler.
examples/companion_radio/main.cpp Passes led_ble_mode into BLE interface initialization.
examples/companion_radio/NodePrefs.h Adds LED mode constants and persisted fields led_ble_mode / led_status_mode.
examples/companion_radio/MyMesh.cpp Adds CLI Rescue commands set led.ble and set led.status.
examples/companion_radio/DataStore.cpp Persists the new LED preference fields.
arch/nrf52/extra_scripts/patch_bluefruit.py Patches Bluefruit to guard blink callback LED toggling behind _led_conn and exposes the callback as a friend.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fdlamotte
Copy link
Collaborator

Hi, interesting commit

But I find this is very specific to a device to make a new command in the protocol

Why didn't you use a custom var instead (as for the gps toggle) ? It's a generic approach and it removes the burden of writing the client part (that does not have to worry about if the feature exists on the companion)

@andyshinn
Copy link
Author

Sure that makes sense. I reworked it to be a custom var instead.

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.

3 participants