Skip to content

fix: propagate application write rejections as ATT Error Responses (backport to 2.5) - #444

Open
jie-meng wants to merge 1 commit into
h2zero:release/2.5from
jie-meng:backport/write-error-propagation-2.5
Open

fix: propagate application write rejections as ATT Error Responses (backport to 2.5)#444
jie-meng wants to merge 1 commit into
h2zero:release/2.5from
jie-meng:backport/write-error-propagation-2.5

Conversation

@jie-meng

@jie-meng jie-meng commented Sep 3, 2026

Copy link
Copy Markdown

Backport of #442 to the release/2.5 branch.

Summary

This backports the fix for propagating application-layer write rejections as ATT Error Responses to the 2.5 release branch.

Changes

  • NimBLECharacteristic: Added setWriteError(uint8_t) and getWriteError() const methods
  • NimBLECharacteristic::writeEvent(): Resets error slot before each write
  • NimBLEServer::handleGattEvent(): Returns the write error for characteristic writes (descriptor writes still return 0)

Usage

Applications can now reject writes in onWrite() callbacks:

void MyCallbacks::onWrite(NimBLECharacteristic* pChar, NimBLEConnInfo& connInfo) {
    if (deviceBusy) {
        pChar->setWriteError(0x80); // vendor-specific error code
        return;
    }
    // process write normally
}

Testing

  • Verified compile against ESP-IDF 5.x
  • Verified the write error is correctly returned to the BLE client as ATT Error Response

@h2zero - this is the backport requested in #442 comment. Would appreciate a review/merge when you have cycles.

…ackport to 2.5)

Backport of h2zero#442 to the release/2.5 branch.

- NimBLECharacteristic: Added setWriteError(uint8_t) and getWriteError() const
- NimBLECharacteristic::writeEvent(): Resets error slot before each write
- NimBLEServer::handleGattEvent(): Returns write error for characteristic writes

Co-authored-by: Jie Meng <jmengxy@gmail.com>
@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 6cd1b899-c309-4d82-a295-fa0d70466991

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jie-meng

jie-meng commented Sep 3, 2026

Copy link
Copy Markdown
Author

@h2zero - this is the backport of #442 to release/2.5 as discussed in #442. Our downstream project is pinned to 2.5.x and needs this fix. Would appreciate a review when you have cycles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant