Synchronize the ESP32 BLE receive queue#3007
Merged
ripplebiz merged 2 commits intoJul 21, 2026
Merged
Conversation
axhoff
marked this pull request as ready for review
July 20, 2026 14:51
Member
|
Wow, I did a bit of research and it's news to me that the Arduino BLE classes don't wrap the operations/callbacks into thread-safe accessors. Yoiks! So, in that case, we should just use an RTOS Queue, eg |
Author
|
Thanks @ripplebiz — good call on using the RTOS primitive. I replaced the custom queue and critical section with a statically allocated FreeRTOS queue using |
hermes-gadget
added a commit
to gadgethd/MeshCore-MQTT
that referenced
this pull request
Jul 22, 2026
Upstream dev: 7ecb2cb..78240e9 (6 commits) 3885c67 fix: synchronize BLE receive queue 9fd6b41 fix: preserve bonded BLE reconnects 4d4d7c3 refactor: use FreeRTOS BLE receive queue 8b048ab Merge pull request meshcore-dev#3007 4157e43 Merge pull request meshcore-dev#3005 78240e9 optimised: value-init not needed Clean auto-merge (no conflicts). MQTT additions preserved.
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.
Summary
Root cause
The BLE callback task appended to
recv_queuewhile the Arduino loop task read, decremented, shifted, and cleared the same array without synchronization. Closely spaced frames could therefore observe partially published state or race with draining and clearing.Scope
Only the receive queue is changed.
xQueueSend(..., 0)retains the existing drop-newest behavior when all four slots are occupied,xQueueReceive(..., 0)keeps reads non-blocking, andxQueueResethandles clear/reset. Static allocation avoids introducing heap allocation or queue-lifetime management.Validation
git diff --checkpio test -e native— 13/13 tests passedpio run -e Xiao_S3_WIO_companion_radio_bleFixes #2923