GoogleChrome / samples

A repo containing samples tied to new functionality in each release of Google Chrome.
https://www.chromestatus.com/samples
Apache License 2.0
5.77k stars 2.39k forks source link

Bluetooth LE watchAdvertisements doesn't work on Linux Ubuntu + Chrome while it works on Android or Windows #794

Open gregoiregentil opened 1 year ago

gregoiregentil commented 1 year ago

A clean install of Ubuntu 22.04 LTS with the latest version of Google Chrome as of February 2023 such as 110, watchAdvertisements doesn't work in the sense that no device is seen. There is no error on the page https://googlechrome.github.io/samples/web-bluetooth/watch-advertisements-and-connect.html, it just says:

> Requested AutoCamera`
Getting existing permitted Bluetooth devices...
> Got 1 Bluetooth devices.
Watching advertisements from "AutoCamera"...

The same page on Android or on Windows 10 (even with an old Google Chrome) is working, it lists the advertisements and successfully connects to the device.

Once again, a live ISO of Ubuntu 22.04 LTS with google-chrome.deb installed shows up the problem.

beaufortfrancois commented 1 year ago

Linux is not supported for now. See https://github.com/WebBluetoothCG/web-bluetooth/blob/main/implementation-status.md#scanning-api

gregoiregentil commented 1 year ago

OK. Thank you.

I'm using Linux+Chrome for development purpose. The page says that "GATT Server Connect" is supported. But I tried device.gatt.connect() on the response of navigator.bluetooth.requestDevice() but it doesn't succeed. Once again, the same device is connected from Windows + chrome upon reception of the Advertisement watch.

I'm in a case which I own the device with its Gatt server. Is there a way to manage to connect to a BLE device from Linux+Chrome without using scanLE and without watch advertisement?

beaufortfrancois commented 1 year ago

Does this help?

If you own the device, can you expose the GATT Battery Service and try https://googlechrome.github.io/samples/web-bluetooth/battery-level-async-await.html?

gregoiregentil commented 1 year ago

Ubuntu 22.04 is way beyond kernel 3.19 and BlueZ 5.41. I'm on Ubuntu 20.04 (kernel 5.15 and bluez 5.53) and I can connect to the device from a plain C application.

request device works and I get a structure such as {deviceId: 'ui5gjtwifKM+.....', name: 'AutoCamera'}. But the connect() fails.

And the connect works in Android.

I really would like to make this work because it will save me a lot of time to work on Linux+Chrome.

gregoiregentil commented 1 year ago

The error in Linux is "connect error: DOMException: Connection Error: Connection attempt failed."

beaufortfrancois commented 1 year ago

Could you file a web bluetooth bug at https://crbug.com/new and follow https://www.chromium.org/developers/how-tos/file-web-bluetooth-bugs/#linux instructions?

gregoiregentil commented 1 year ago

I'm not totally sure of my own implementation of the Gatt server on my device, but the same "very simple" page works on Android and fails on Linux. And it also works in a native Android java app, as well as in a native Linux C app.

I have emailed you a full log report (to fbe....com)

beaufortfrancois commented 1 year ago

As shared by email, it looks like a Bluez issue:

= bluetoothd: 70:2C:1F:6C:81:4A: error updating services: Connection refused (111)