How can I get the Eddystone URL beacon info through Web Bluetooth api?

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.

Upvotes: 0

Views: 545

Answers (2)

davidgyoung
davidgyoung

Reputation: 64941

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

Upvotes: 2

François Beaufort
François Beaufort

Reputation: 5649

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.

Upvotes: 3

Related Questions