capacitor-community / bluetooth-le

Capacitor plugin for Bluetooth Low Energy
MIT License
284 stars 86 forks source link

Web Bluetooth (Chrome Ubuntu) Scanning #704

Open vicatcu opened 4 weeks ago

vicatcu commented 4 weeks ago

Describe the bug I get a permission prompt when i initiate a Bluetooth scan using BleClient.requestLEScan but

To Reproduce Steps to reproduce the behavior: Do all the pre-requisite enablement of experimental features in chrome://flags as shown here: image

Enable Bluetooth in the operating system settings and observe that scan results are apparent in the system dialog.

Set a breakpoint in Chrome Dev Tools in the callback function for:

BleClient.requestLEScan(
   {services: []}, 
   (result) =>  {
      console.log(result); // set breakpoint here
   }
)` 

... and observe that it never executes, despite the same code working fine on iOS and Android builds.

The following prompt appears in Chrome: image

... but clicking "Allow" doesn't make a difference, and Chrome doesn't seem to "remember" that I clicked allow either - it asks every time.

Expected behavior Invoking a Bluetooth scan should cause the callback to fire in Web Bluetooth same as on iOS and Android. Allow dialog should not come up every time a scan is invoked?

Screenshots N/A

Plugin version:

Desktop (please complete the following information):

Additional context NodeJS : v18.20.2 npm : 10.5.0 OS : Linux 6.9 Angular: 16.2.9 @ionic/angular@8.3.1 @capacitor/cli: 5.7.5 @capacitor/core: 5.7.8

pwespi commented 3 weeks ago

Note that requestLEScan of Web Bluetooth is still experimental and has bugs. On the implementation status page Linux is not even listed as supported. Therefore I don't think there is anything that can be done about this in the plugin.

You could try to use navigator.bluetooth.requestLEScan directly and I suspect you would get the same results.