-
Notifications
You must be signed in to change notification settings - Fork 306
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
client.write_gatt_char() not exposing GATT error code to user #174
Comments
It will not be done in the foreseeable future I am afraid. I am swamped with other (paid) work and cannot guarantee doing anything with this project for quite some time. I will still address PRs to |
This is a very good suggestion. Implemented a version of this (2cf7b8b) on the |
Excellent! Will this be implemented in the two other backends as well? |
Right now, no. I am not sure where to fetch that information in BlueZ nor in Core Bluetooth. Bleak is very much a “each one to one’s own” in the sense that if you ask for it and do most of the actual detective work of the development, I will probably integrate it. If someone needs it, they are free to go look for it and I will eventually try to merge their OR or in this case request. On that note, please try out the dev branch and see if you can reproduce the errors and verify the solution! |
@Matt-Hicks-Bose These error codes, where did you find specifications of them? Another user got a |
The error codes used by GATT are defined in the Bluetooth Core Specification (Version 5.2, Vol 3, Part H, Section 3.4.1.1, Table 3.4 (pp. 1491)), which is available to download here: https://www.bluetooth.com/specifications/bluetooth-core-specification/ I will add a comment to the other issue with more details about the error code. |
@Matt-Hicks-Bose Thank you! I will try to include those error codes in bleak for future use. |
Added text strings of these errors codes in 37597b3 and showing these when raising Protocol Errors. Thank you @Matt-Hicks-Bose; it will be included in version 0.8.0, after which I will close this issue and open two new ones for BlueZ and Core Bluetooth backends. It would be nice to provide the same details there, but I am not sure it is possible. |
Will close for now. I have had no success finding GATT error codes in BlueZ or Core Bluetooth. |
bluetoothctl -v
) in case of Linux: N/ADescription
I am working with a BLE device that will return an application specific ATT error response (between 0x80 - 0x9F, as required by the Bluetooth specification) when a characteristic is written with invalid data. I am writing to this characteristic with
client.write_gatt_char()
and specifyingresponse=True
. However, when I run this code with intentionally invalid data, I am getting aBleakError
without the ATT error response, because of this I cannot handle the error in my own code correctly.What I Did
When I run this my output looks like:
It is expected that an ATT error response would be returned or raised, but the python error raised does not indicate what the ATT error response was.
Further investigation
I looked through the .NET documentation that was mentioned in #59 ( https://docs.microsoft.com/en-us/uwp/api/windows.devices.bluetooth.genericattributeprofile.gattwriteresult ), and it looks like the ATT error response is contained in the
ProtocolError
property of thegattwriteresult
object. On my local copy of the library I changed theBleakError
raised inwrite_gatt_char()
, part of the dotNET backend from:To:
This now results in an error that shows the expected ATT error response
0x90
which in this application means "invalid configuration requested":Is it possible to expose this ATT Error Response to the user of the library? Either through a seperate error message that could be caught and handled, a return value, or some other mechanism?
The text was updated successfully, but these errors were encountered: