ble_hci: fill in the handle and error code of an ATT Error Response - #11145
Open
annejan wants to merge 1 commit into
Open
ble_hci: fill in the handle and error code of an ATT Error Response#11145annejan wants to merge 1 commit into
annejan wants to merge 1 commit into
Conversation
send_error() takes a handle and an error code and then ignored both: the initialiser only set the two opcodes, so every Error Response the device sent carried handle 0x0000 and error code 0x00. 0x00 is not a valid ATT error code, and a client may treat such a response as malformed. BlueZ does. During service discovery it reads Server Supported Features (0x2B3A), no attribute matches, the malformed error comes back, and it abandons the ATT bearer and finishes with an empty database. The peripheral then appears to have no services at all, even though its Read By Group Type Responses were correct. Found on an nRF52840 talking to BlueZ, by reading the ATT exchange over SWD. With the fields filled in, that read is answered with Attribute Not Found, discovery proceeds, and the client sees every service and characteristic.
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.
send_error()in the HCI_bleioATT server takes a handle and an error code and then ignores both. The initialiser only sets the two opcodes:So every ATT Error Response the device sends carries handle
0x0000and error code0x00.0x00is not a valid ATT error code, and a client may reasonably treat the response as malformed. BlueZ does. During service discovery it issues a Read By Type Request for Server Supported Features (0x2B3A); no attribute matches, so the server correctly wants to answer Attribute Not Found, but the malformed error goes out instead. BlueZ abandons the ATT bearer and completes discovery with an empty database.The visible symptom is a peripheral that appears to have no services at all, even though its Read By Group Type Responses are byte-for-byte correct.
ServicesResolvedbecomes true andUUIDsis empty.How this was found
On an nRF52840 running the HCI
_bleiohost against an on-chip controller, by capturing the ATT exchange over SWD. The request and the reply we sent:With the fields filled in, the same read is answered with Attribute Not Found, discovery proceeds, and a client sees every service and characteristic. Verified with
bleakandbluetoothctl: service count goes from 0 to 3, and characteristic writes then work end to end.