OpenBluetoothToolbox / SimpleBLE

SimpleBLE - the all-in-one Bluetooth library for MacOS, iOS, Windows, Linux and Android.
https://www.simpleble.org
Other
660 stars 111 forks source link

Inconsistent set_callback_on_scan_updated callback behavior. #333

Open Jah-On opened 1 month ago

Jah-On commented 1 month ago

When using SimpleBLE::Safe::Adapter and SimpleBLE::Safe::Peripheral, the callback exhibits different behavior on Linux and Windows. For starters, Linux updates far less frequently and seems to stop after one or two updates. It seems like changes in RSSI do not trigger the callback. However, on Windows, RSSI changes do trigger the callback with it getting called at least every second per device.

On a somewhat related issue, the behavior for indicating whether a discovered device is no longer connectable is inconsistent too. On Linux, not such indication is given in either via the callback which is never triggered or repeatedly checking the values of stored discovered devices whose member attributes never change including RSSI or is_connectable(). It is worth noting that I am using pass by reference and pointers to pass around and store the Peripherals fed into the callback in downstream classes and functions. On Windows, the RSSI does eventually become -127 after exactly one minute of the Bluetooth being powered off. While it's certainly an improvement over no indication, it's quite a long time. For applications that rely on user selection where the list needs to be updated to only show devices that are still connectable, a delay of five to ten seconds is approaching the upper limit of acceptable.

I'm sure there are OS specific quirks for each of these things but it'd be nice to have a proper understanding of these differences to handle them accordingly. Any ideas for how to work around them?

Thank you!