Use runtime BLE name based on MAC address#108
Merged
zjwhitehead merged 6 commits intomasterfrom Apr 1, 2026
Merged
Conversation
Build a runtime advertising name from the device MAC and use it for BLE advertising instead of the hardcoded kAdvertisingName. Add gAdvertisingName buffer and kAdvertisingNameCapacity, plus initAdvertisingName() to construct a per-device name (and return an uppercase unique ID string). Replace earlier setName usages to reference gAdvertisingName and move the advertising name assignment into the payload configuration path. Change include from <cctype> to <cstdio> to use snprintf, and update NimBLEDevice::init() to initialize NimBLE before the advertising-name initialization (initAdvertisingName() must be called after NimBLEDevice::init()). Also add prototypes for helper functions shouldAdvertiseWhilePowered() and startAdvertising().
Display a Bluetooth symbol on the main LVGL screen to indicate BLE pairing mode and add a flashing indicator for it. Declares ble_pairing_icon in the header, creates the label in lvgl_main_screen (font, color, alignment, hidden by default), and adds ble_pairing_flash_timer and isFlashingBLEPairingIcon state in lvgl_updates. Implements ble_pairing_flash_timer_cb, startBLEPairingIconFlash and stopBLEPairingIconFlash with mutex protection, proper timer creation/deletion and error handling. Wire up start/stop calls: start when pairing is entered via button hold, and stop on pairing timeout and on new BLE connections in ble_core. This provides a visible, thread-safe pairing-mode indicator for users.
Add BLE_PAIR_ON_BOOT build flag and conditional logic to automatically enter BLE pairing mode during setup. platformio.ini now defines -D BLE_PAIR_ON_BOOT, and setupBLE() prints a notice and calls enterBLEPairingMode() and startBLEPairingIconFlash() when the flag is set, enabling firmware builds that start pairing on boot.
Change the BLE advertising name format to include only the last two MAC bytes and wrap them in brackets. The snprintf call was updated from "%s %02X%02X%02X" using mac[3],mac[4],mac[5] to "%s [%02X%02X]" using mac[4],mac[5], shortening and reformatting the device name.
Adjust BLE pairing icon placement in the main screen (use lv_obj_set_pos(103,72) instead of lv_obj_align) and add test coverage for the BLE pairing indicator. Tests include light and dark screenshot cases plus reference BMPs. Also update the emulator teardown to clear ble_pairing_icon, its flash timer and flash state so tests start from a clean state.
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.
Build a runtime advertising name from the device MAC and use it for BLE advertising instead of the hardcoded kAdvertisingName. Add gAdvertisingName buffer and kAdvertisingNameCapacity, plus initAdvertisingName() to construct a per-device name (and return an uppercase unique ID string). Replace earlier setName usages to reference gAdvertisingName and move the advertising name assignment into the payload configuration path. Change include from to to use snprintf, and update NimBLEDevice::init() to initialize NimBLE before the advertising-name initialization (initAdvertisingName() must be called after NimBLEDevice::init()). Also add prototypes for helper functions shouldAdvertiseWhilePowered() and startAdvertising().