Enhance BLE reconnect handling and decouple UI updates#110
Open
zjwhitehead wants to merge 4 commits intomasterfrom
Open
Enhance BLE reconnect handling and decouple UI updates#110zjwhitehead wants to merge 4 commits intomasterfrom
zjwhitehead wants to merge 4 commits intomasterfrom
Conversation
Introduce a 5-minute reconnect window and UI status control for BLE advertising/connection handling. Adds reconnect window timer/flag and init logic so whitelist advertising after boot or disconnect only runs while the reconnect window is active; advertising logic now checks reconnectWindowActive instead of relying solely on bond count. Add updateBLEStatusIcon(), showBLEStatusIcon(), and hideBLEStatusIcon() and wire status updates across BLE lifecycle events; LVGL changes centralize pairing/status icon show/hide and make stopBLEPairingIconFlash delegate to hideBLEStatusIcon. Remove some legacy scan-response manufacturer payload code paths and stop triggering the pairing-icon flash from the main button handler. Also comment out the BLE_PAIR_ON_BOOT build flag in platformio.ini.
Remove direct UI calls from BLE core and move BLE pairing icon management into the LVGL UI task. Added isBLEPairingModeActive() to ble_core.h/.cpp so the UI can query pairing state, removed updateBLEStatusIcon() and its calls from ble_core.cpp to decouple BLE logic from display code, and updated lvgl_updates.cpp to include BLE headers and keep the pairing icon in sync (managing the flash timer and visibility). This reduces cross-module coupling and ensures missed callback updates are recovered by the UI task.
Remove the reconnect-window feature and related state/timers from the BLE core (kReconnectWindowTicks, gReconnectWindowTimer, reconnectWindowActive and associated functions). Advertising logic is simplified so bonded devices may always reconnect via whitelist advertising (shouldAdvertiseWhilePowered now checks NimBLEDevice::getNumBonds()). Cleanup removes timer management and reconnect-window handling from connection callbacks, setup, and pairing transition, reducing complexity and reliance on a 5-minute reconnect timer.
Capture and remove the LVGL splash screen to avoid leftover objects and force an initial repaint of the main screen before other tasks contend for SPI. Added a splash_screen pointer (lv_screen_active()), invalidate and refresh the main_display immediately (lv_obj_invalidate + lv_refr_now), and delete the splash screen if it differs from the main screen. Also cleaned up .vscode/extensions.json by removing a duplicate PlatformIO recommendation.
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.
This pull request introduces a "reconnect window" feature for BLE advertising, refines the BLE pairing mode logic, and improves BLE status icon handling in the UI. The reconnect window allows previously bonded devices a 5-minute period after boot or disconnect to reconnect before reverting to whitelist-only advertising. BLE status icon updates are now more robust and better synchronized with BLE state.
BLE Core Logic Improvements:
reconnectWindowActive, associated timers, and logic inble_core.cpp). [1] [2] [3] [4]shouldAdvertiseWhilePowered,startAdvertising). [1] [2]isBLEPairingModeActive()for UI and logic integration. [1] [2]UI and BLE Status Icon Handling:
showBLEStatusIcon()andhideBLEStatusIcon()to control the BLE icon, and improved icon state synchronization inupdateLvglMainScreento reflect actual BLE connection and pairing mode status. [1] [2] [3]Configuration and Code Cleanups:
platformio.ini(commented outBLE_PAIR_ON_BOOT).These changes improve user experience by providing a grace period for device reconnection, ensuring the BLE status icon accurately reflects BLE state, and cleaning up advertising and configuration logic.