Fix BLE byte counter regression introduced in 9.0.0 #2542
Merged
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.
User description
Summary
Fixes BLE connection byte counter always showing 0, which also caused MSP request timeouts over BLE.
See #2538
Root Cause
In 8.0.0,
Connection.addOnReceiveListener()called both_onReceiveListeners.push()ANDaddOnReceiveCallback(), which registered the byte counter callback in BLE's separate listener array. In 9.0.0 this was changed to only push to_onReceiveListeners(to avoid duplication in Serial/TCP/UDP which share the same array). BLE was the only connection type with a separate array, so it silently lost the byte counter callback.Changes
_onCharateristicValueChangedListenersarrayaddOnReceiveCallback()andremoveOnReceiveCallback()to use the base class_onReceiveListenersarray, matching the pattern Serial already uses_onReceiveListenersdirectlyTesting
Note on Debug Logging
This PR intentionally includes temporary
[BLE FIX]console.log statements (4 total, marked with TODO comments) to help verify the fix when tested with real BLE hardware. These should be removed in a follow-up once the fix is confirmed working.PR Type
Bug fix
Description
Fixes BLE byte counter regression showing zero bytes received
Aligns BLE connection with Serial pattern using shared listener array
Removes BLE-specific characteristic listener array causing callback loss
Adds temporary debug logging to verify fix with BLE hardware
Diagram Walkthrough
File Walkthrough
connectionBle.js
Align BLE listener pattern with Serial implementationjs/connection/connectionBle.js
_onCharateristicValueChangedListenersarray from constructoraddOnReceiveCallback()to push to_onReceiveListenersinsteadof BLE-specific array
removeOnReceiveCallback()to filter_onReceiveListenersinstead of BLE-specific array
_onReceiveListenersdirectly with debug logging
[BLE FIX]console.log statements marked with TODOfor removal after testing