Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the GATT client to allow use of Write Without Response characteristics #302

Merged
merged 2 commits into from
Mar 3, 2025

Conversation

Meigs2
Copy link
Contributor

@Meigs2 Meigs2 commented Feb 26, 2025

Summary

Some BLE devices expose the attribute "Write Without Response" on characteristics. Currently, trouble only supports writing with responses. This PR extends the GATT client to support Write Without Response.

Implementation

According to the BLE Spec regarding Write Without Response, the end of section 3.4.5.3 reads:

No ATT_ERROR_RSP or ATT_WRITE_RSP PDUs shall be sent in response to this command. If the server cannot write this attribute for any reason the command shall be ignored

Therefore, we should be able to re-use existing logic in the request method for the GATT client to send the message, and not wait on a response from the response_channel.

I've added a new method, write_characteristic_without_response which invokes this new Write command process

Testing

I've tested this on an Acaia Lunar 2021 which exposes a Write Without Response characteristic, writing to this before would cause an WRITE_NOT_PERMITTED = 0x03 error code from the host layer. Utilizing the new method allows me keep a long-lived connection open with the scale. This was tested on an ESP32C3 dev board.

@Meigs2 Meigs2 changed the title Update the GATT client to allow for use of Write Without Response characteristics Update the GATT client to allow use of Write Without Response characteristics Feb 26, 2025
Copy link
Member

@lulf lulf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for fixing!

@lulf
Copy link
Member

lulf commented Feb 27, 2025

/test

@lulf lulf merged commit 7011959 into embassy-rs:main Mar 3, 2025
3 checks passed
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.

2 participants