fix(nrf52): add BLE security timeout and advertising watchdog#2089
Open
ipduffy wants to merge 1 commit intomeshcore-dev:devfrom
Open
fix(nrf52): add BLE security timeout and advertising watchdog#2089ipduffy wants to merge 1 commit intomeshcore-dev:devfrom
ipduffy wants to merge 1 commit intomeshcore-dev:devfrom
Conversation
This was referenced Mar 19, 2026
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.
Commit 25ea953 introduced a condition where a BLE connection that is established but not yet encrypted could result in a hung BLE stack under certain conditions.
If
onConnectis called with a valid connection_handle, the_isDeviceConnectedflag remains set to false. This prevents the watchdog loop on lines 336-346 from running until after theonSecuredfunction is called and the_isDeviceConnectedflag is set to true.For various reasons that are apparently more common in iPhones versus Android devices, the establishment of encryption is more likely to not complete, which would leave the nRF device BLE stack in a hung state.
To address this potential for a hung state I've implemented a timeout (BLE_SECURITY_TIMEOUT_MS) on the call to
onSecuredof 15 seconds, so that if a BLE connection is established viaonConnectwithout the subsequent call toonSecuredwithin that time, thendisconnectis called, allowing the device to return to an advertising state and allow further connection attempts.I have tested this patched firmware on a RAK 4631 board and it's been stable without any BLE issues for the past 24 hours.