-
Notifications
You must be signed in to change notification settings - Fork 304
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
Potential performance improvements on Windows? #56
Comments
After opening this issue, I stopped debugging the PC side in the anticipation of your answer and switched to developing new feature in the firmware. After working on firmware and analyzing debugger's RTT output, I discovered that when connecting to the PC, the PPCP (Peripheral Preferred Connection Parameters) were not updated - in FW I had Minimum Connection Interval set to 7.5 ms (minimum), but Maximum Connection Interval was set to 500 ms. It looks like the Android phone automatically updated the intervals to shortest allowed, which Windows does not (power saving?). After setting the Maximum Connection Interval = Minimum Connection Interval = 7.5 ms in the firmware, there are no lost notifications anymore. Sorry for the inconvenience. |
Interesting read, and good to see that bleak actually holds up even though it is an experimental wrapping of .NET code into Python! Good to see that you could resolve it; that was a setting in the peripheral's code, am I right? Regarding the proposed changes:
|
develop
branch)Description
I am wondering about spots where the potential performance improvements could be made. This library is working great overall, however I am pushing the performance limits. My device is sending 500 notifications per second (of BLE max. 800) and I am not able to receive all of them. Using the code posted under What I Did below, the print output is:
iOS and Android apps are able to receive the notifications, so I set my goal to be able to receive them with Bleak as well.
I don't know where it would be the best to start. Would Make binary wheels for Windows noticeable improve performance?
What I Did
I am currently working on my own branch with following improvements:
BluetoothLEAdvertisementWatcher
, which listens for BLE advertisements (without enumeration) and also supports additional filtering based on advertisement and scan response data.BluetoothLEDevice.FromBluetoothAddressAsync
to directly get the device instance from the MAC address and only perform (2 s) discovery combined withBluetoothLEDevice.FromIdAsync
if the first method is not successful (6f130fa)BleakGATTCharacteristic
directly without always re-querying them in I/O methods (002e7f9). This is more usability than performance improvement, as I usually make (data)classes for my services and retrieve all characteristics in the__init__
.More important, this also supports the cases where the same SIG characteristic (e.g. Analog) is present in multiple services as one can call
service.get_characteristic()
on multiple service instances. Stripped example of my usage:I haven't opened the PR as my changes are Python >=3.6.
The text was updated successfully, but these errors were encountered: