fix(ble): Fix inconsistency in write callback order#12266
fix(ble): Fix inconsistency in write callback order#12266me-no-dev merged 2 commits intoespressif:masterfrom
Conversation
👋 Hello lucasssvaz, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
Test Results 90 files 90 suites 31m 7s ⏱️ Results for commit 15b1705. ♻️ This comment has been updated with latest results. |
Memory usage test (comparing PR against master branch)The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.
Click to expand the detailed deltas report [usage change in BYTES]
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
This pull request refactors the BLE characteristic write callback timing for both Bluedroid and NimBLE stacks to ensure the onWrite callback is invoked before the write response is sent to the client. The PR also includes a bug fix for parameter access in the ESP_GATTS_EXEC_WRITE_EVT handler and removes the deferred callback mechanism that was used for NimBLE.
Changes:
- Modified callback timing to invoke
onWritebefore sending write responses for both Bluedroid and NimBLE stacks - Fixed incorrect parameter access in
ESP_GATTS_EXEC_WRITE_EVThandler (changed fromparam->write.*toparam->exec_write.*) - Removed the deferred write callback mechanism for NimBLE, including the
processDeferredWriteCallbackfunction andDeferredWriteCallbackstruct
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| libraries/BLE/src/BLECharacteristic.h | Removed DeferredWriteCallback struct and processDeferredWriteCallback method declaration |
| libraries/BLE/src/BLECharacteristic.cpp | Changed callback timing for both stacks to invoke before response; fixed exec_write parameter access bug; removed deferred callback implementation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Description of Change
This pull request refactors how the BLE characteristic write callback (
onWrite) is invoked for both Bluedroid and NimBLE BLE stacks. The main improvement is to ensure that theonWritecallback is called before the write response is sent to the client, guaranteeing that the write has been processed when the client receives acknowledgment. This change also removes the deferred callback mechanism used for NimBLE, simplifying the codebase and aligning behavior between the two stacks.Callback invocation timing improvements:
onWritecallback inBLECharacteristic::handleGATTServerEventis now invoked before sending the write response for both Bluedroid and NimBLE, ensuring the write is processed before acknowledgment is sent to the client. [1] [2] [3]Codebase simplification and cleanup:
processDeferredWriteCallbackfunction and related struct definitions, since the callback is now invoked synchronously. [1] [2] [3]Behavior alignment:
These changes improve reliability for BLE clients and simplify maintenance by making callback handling more predictable and consistent across BLE stacks.
Test Scenarios
Tested locally with NimBLE and Bluedroid