0

I am trying to list a eddystone url beacon through web bluetooth api. I am using the sample code filtering by 0xfeaa as Bluetooth service. I also try using any of the UUIDs listed in Eddystone Configuration Service page.

The beacon looks configured properly since with the Beacon Simulator app I can see it through the scanner, and I can see the its service UUID as 0000FEAA-... as expected (see below).

Eddystone configuration from Beacon Simulator app

The aim is to get the url with Web API methods, instead of using a native app.

2 Answers2

3

FYI bluetooth beacons (iBeacon or eddystone) are filtered out from scan results on Android 12+

As noted in https://bugs.chromium.org/p/chromium/issues/detail?id=1296054#c7, as of Android 12 Bluetooth permissions have been extended to include the "neverForLocation" flag.

Chrome includes this flag because the Web Bluetooth API is not intended for determining user location as a replacement for the Geolocation API.

You can read more at https://bugs.chromium.org/p/chromium/issues/detail?id=1324831 as well.

François Beaufort
  • 4,843
  • 3
  • 29
  • 38
2

Web Bluetooth scanning is an experimental feature in Chrome. Note this warning:

Note: Scanning is still under development. You must be using Chrome 79+ with the chrome://flags/#enable-experimental-web-platform-features flag enabled.

https://googlechrome.github.io/samples/web-bluetooth/scan.html

If you enable that, you should be able to scan for devices with service UUID 0xFEAA, then parse out the service data:

event.serviceData.forEach((valueDataView, key) => {
  logDataView('Service', key, valueDataView);
});

You should see the URL encoded in those service data bytes using a special compression algorithm of Eddystone-URL. You will need to write JavaScript to decode this compression as described here:

https://github.com/google/eddystone/tree/master/eddystone-url

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • I try with [Device Info sample](https://googlechrome.github.io/samples/web-bluetooth/device-info.html), which make use of `requestDevice()` instead of `requestLEScan()`, and didn't work out though :( For the purpose of list the device at least, are both methods similars? – Alberto Sanchez Gonzalez Jul 07 '22 at 08:10
  • deviceInfo will not give you service advertisement scan data, so you can't use that, you must use the scanning APIs I mention. This should allow you to do what you want on Chrome platforms that don't block Eddystone detection (although per the answer by @françois-beaufort, it may not be possible to get this to work on Android 12+ until/unless Google makes other changes). – davidgyoung Jul 07 '22 at 12:55