-
Notifications
You must be signed in to change notification settings - Fork 305
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
InvalidStateError after callback #675
Comments
Can you please share a full program to reproduce the error? |
I added an example code. I also noticed that this line is the problem. When I remove it the error goes away.
Why cant I read the value before adding the callback? Did I do something wrong here? |
Thanks for updating. Read and notify use the same underlying callback in CoreBluetooth, so I think I see how the bug is happening now. It is a problem in Bleak. |
In the CoreBluetooth backend, futures are used to pass results/errors from the delegate callbacks to methods that are waiting for them. The futures are stored as part of the object state so that the delegates can access them. Prior to this change, completed futures were not removed from the object status. This worked most of the time because a second call of the same method would replace the completed future from the prior call. However, in the case of notifications and reads, the same delegate callback is shared with two methods. So when both of these were used, notifications would attempt to complete the already completed read future which raises an InvalidStateError. Fixes #675.
Thanks for your fast fix. Unfortunately I am unable to connect anymore.
I got this error message:
|
In the CoreBluetooth backend, futures are used to pass results/errors from the delegate callbacks to methods that are waiting for them. The futures are stored as part of the object state so that the delegates can access them. Prior to this change, completed futures were not removed from the object status. This worked most of the time because a second call of the same method would replace the completed future from the prior call. However, in the case of notifications and reads, the same delegate callback is shared with two methods. So when both of these were used, notifications would attempt to complete the already completed read future which raises an InvalidStateError. Fixes #675.
Thanks for trying. I just force pushed a change that should hopefully fix the |
Thanks it works now. It connects successfully and the callback works without any errors. |
Added ----- * Added ``service_uuids`` kwarg to ``BleakScanner``. This can be used to work around issue of scanning not working on macOS 12. Fixes #230. Works around #635. * Added UUIDs for LEGO Powered Up Smart Hubs. Changed ------- * Changed WinRT backend to use GATT session status instead of actual device connection status. * Changed handling of scan response data on WinRT backend. Advertising data and scan response data is now combined in callbacks like other platforms. * Updated ``bleak-winrt`` dependency to v1.1.0. Fixes #698. Fixed ----- * Fixed ``InvalidStateError`` in CoreBluetooth backend when read and notification of the same characteristic are used. Fixes #675. * Fixed reading a characteristic on CoreBluetooth backend also triggers notification callback. * Fixed in Linux, scanner callback not setting metadata parameters. Merged #715.
Added ----- * Added ``service_uuids`` kwarg to ``BleakScanner``. This can be used to work around issue of scanning not working on macOS 12. Fixes #230. Works around #635. * Added UUIDs for LEGO Powered Up Smart Hubs. Changed ------- * Changed WinRT backend to use GATT session status instead of actual device connection status. * Changed handling of scan response data on WinRT backend. Advertising data and scan response data is now combined in callbacks like other platforms. * Updated ``bleak-winrt`` dependency to v1.1.0. Fixes #698. Fixed ----- * Fixed ``InvalidStateError`` in CoreBluetooth backend when read and notification of the same characteristic are used. Fixes #675. * Fixed reading a characteristic on CoreBluetooth backend also triggers notification callback. * Fixed in Linux, scanner callback not setting metadata parameters. Merged #715.
Description
When the callback of a subscribed characteristic is called I get an asyncio exception. The value which gets passed into the callback is correct.
This started happening with version 0.12.0. There is no error on 0.11.0.
The text was updated successfully, but these errors were encountered: