canonical / bluez.dart

Mozilla Public License 2.0
52 stars 20 forks source link

Scanning not showing all (BLE?) devices unless GNOME Setttings is open... #91

Closed Kazade closed 1 year ago

Kazade commented 1 year ago

Hi!

I have an interesting problem where I'm trying to write Flutter code to talk to a proprietary BLE device. If I scan for devices using the bluez package I get a list of devices nearby, but not the one I'm interested in.

However! If I open the GNOME bluetooth settings panel while scanning, the BLE device immediately starts being returned by bluez.dart!

So my theory is that the GNOME settings panel is setting something over dbus to scan for BLE devices, that bluez.dart isn't (or, I'm not using it properly!).

Any thoughts?

robert-ancell commented 1 year ago

When you access bluez the devices returned are the ones you have configuration for - no scanning is done. To scan for devices you need to call adapter.startDiscovery(), see example/scan.dart for use of this. When you open settings it enables the scanning, which means all bluez clients will see new devices (these are removed later after scanning stops).