Re: Web Bluetooth API - Obtaining RSSI value

1,133 views
Skip to first unread message

Jeffrey Yasskin

unread,
Feb 3, 2017, 11:28:16 AM2/3/17
to Mike Harling, web-bl...@chromium.org
As you've discovered, watchAdvertisements() isn't implemented yet, and there's no other way to get RSSIs. Sorry!

Jeffrey

On Fri, Feb 3, 2017 at 6:40 AM, Mike Harling <mike.h...@rocketmail.com> wrote:
Hello Jeffrey,

I have a question which I wonder if you could help me with.

I am currently experimenting with the Web Bluetooth API and am trying to obtain the RSSI field from a BLE device so I can estimate the distance the device is away from the user.  It's part of a final year university project.

The only way I have found to get the RSSI seems to be through the watchAdvertisements() method documented here:

but looking at the Web Bluetooth implementation status page:

and through my own testing it does not seem to be implemented, at least all I am receiving is an error that watchAdvertisements() is not a method.

The reason I am emailing you is due to your comment here:

you suggest sites to use this method which made me think that is in fact implemented and working.

Are you able to confirm the status of this method for me or suggest another way to obtain the RSSI from a BLE device?

I am testing on Ubuntu 16.04 and Android 6.02 and have tried both the stable and dev branch of Google Chrome.  Below is a small snippet of the code I use.

    navigator.bluetooth.requestDevice({
    filters: anyNamedDevice()
  }).then( device => {
    device.watchAdvertisements();
    device.addEventListener('advertisementreceived', parseBeacon);
  }).catch( error => {
    ...
  });
};

function parseBeacon(event) {
  var rssi = event.rssi;
  ...
}

Regards,
Mike Harling


antoineg...@gmail.com

unread,
Jul 10, 2018, 10:00:34 AM7/10/18
to web-bluetooth, mike.h...@rocketmail.com, jyas...@google.com

Joe Medley

unread,
Jul 10, 2018, 11:44:37 AM7/10/18
to antoineg...@gmail.com, web-bluetooth, mike.h...@rocketmail.com, Jeffrey Yasskin
Mike,

Here's the blink sourcecode where the bluetooth interfaces are defined. In my experience (about 4 years now), the IDL files are rarely, if ever, inaccurate.

https://cs.chromium.org/chromium/src/third_party/blink/renderer/modules/bluetooth/
Joe Medley | Technical Writer, Chrome DevRel | jme...@google.com | 816-678-7195
If an API's not documented it doesn't exist.


--
You received this message because you are subscribed to the Google Groups "web-bluetooth" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web-bluetoot...@chromium.org.
To post to this group, send email to web-bl...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/web-bluetooth/1f890f8e-e878-4835-b122-320e8ae41a34%40chromium.org.

tejchau...@gmail.com

unread,
Feb 22, 2019, 7:43:08 AM2/22/19
to web-bluetooth, mike.h...@rocketmail.com
Dear Mike ,
Even I am working on the same Project that is  Web Bluetooth. 
I have tried to implement your code to find the rssi value of the beacon device , but its showing an error.
Could you please update on how have you obtained the rssi value?
thanking you,



yours Sincerely 
Tej J Chaugule

Mike Harling

unread,
Feb 27, 2019, 2:45:52 PM2/27/19
to web-bluetooth, tejchau...@gmail.com
Hi Tej,

Thanks for getting in touch and sorry for the delay in responding, I had to dig out my code.  I'm afraid the answer is I didn't find a way to obtain the RSSI value using WebBluetooth.

The project I was working on was a proof of concept more than anything else so I created a basic Android application that is easily able to obtain the RSSI value of Bluetooth devices.  The app used a WebView widget that can pass information back and forth between the app and a webpage.  So ultimately I had my website running full screen inside the app and used the app to scan for nearby Bluetooth devices and pass the RSSI value back into the web app.

For my own curiosity I'd be interested to know what project you are working on?  And please let me know if I can help any further.

Good luck!

Thanks
Mike

sunbre...@gmail.com

unread,
Jun 6, 2020, 10:07:48 AM6/6/20
to web-bluetooth, tejchau...@gmail.com, mike.h...@rocketmail.com
https://reelyactive.github.io/web-ble-demo/ shows a way to use "requestLEScan" to get RSSI

在 2019年2月28日星期四 UTC+8上午3:45:52,Mike Harling写道:

Vincent Scheib

unread,
Jun 10, 2020, 1:53:18 AM6/10/20
to sunbre...@gmail.com, web-bluetooth, tejchau...@gmail.com, mike.h...@rocketmail.com, Ovidio Ruiz-Henríquez
requestLEScan() has a prototype that can be experimented with behind flags, however development is currently paused.
chrome://flags/#enable-experimental-web-platform-features

watchAdvertisements() implementation is underway, and can also be experimented with now behind flags.
chrome://flags/#enable-experimental-web-platform-features
chrome://flags/#enable-web-bluetooth-new-permissions-backend


--
You received this message because you are subscribed to the Google Groups "web-bluetooth" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web-bluetoot...@chromium.org.

sunbre...@gmail.com

unread,
Jun 11, 2020, 2:56:08 AM6/11/20
to web-bluetooth, sunbre...@gmail.com, tejchau...@gmail.com, mike.h...@rocketmail.com, odej...@chromium.org
So which one do Chromium teams prefer?

I'm working on an IoT Web SDK that relies on BLE advertisement: https://github.com/notepad-core-js
On Edge 83 (stable)  and Chrome 83 (stable), "requestLEScan" is available but "BluetoothDevice.watchAdvertisement" is not.

在 2020年6月10日星期三 UTC+8下午1:53:18,Vincent Scheib写道:
To unsubscribe from this group and stop receiving emails from it, send an email to web-bl...@chromium.org.

Ovidio Ruiz-Henríquez

unread,
Jun 11, 2020, 12:17:32 PM6/11/20
to sunbre...@gmail.com, web-bluetooth, tejchau...@gmail.com, mike.h...@rocketmail.com
It depends on the use case. requestLEScan() will allow you to see advertisement packets from devices around the system, but you won't the able to connect to these devices without first calling requestDevice() for them. watchAdvertisements() will allow you to see advertisement packets for a device that has already been granted permission to the site.

I recently merged the patch for watchAdvertisements(), so it should be available in Chrome Canary version 85.0.4165.0 or greater now.
Reply all
Reply to author
Forward
0 new messages