Access Beacons from Webpage using JavaScript


#1

Hello,
we are starting a student project using Beacons with Web Bluetooth API.
We have to develop an interactive HTML webpage that use JavaScript
for the access of our three “Estimote Proximity Beacons” from a Chrome browser of a smartphone.

  1. Would you please tell me if it is possible? (We do not develop a native Android application).
    https://webbluetoothcg.github.io/web-bluetooth/
    Is there a way to access estimotes via javascript in browser?
    Using beacons with websites
    Progressive web app beacon search

  2. Are there JavaScript programming examples for the scan of Beacons?
    When we understand correctly our webpage should scan for Beacons cyclically
    but we do not need to connect to the Beacons,
    because the webpage should only know near which Beacon the user is.

Thank you very much

Best regards
Tatjana

Something like that ?
<!DOCTYPE html>
<html>
<body>
<h1>Web Bluetooth API access example</h1>
<p>Scann for Estimote Proximity Beacons</p>

 <!-- JavaScript accessing Bluetooth -->
 
 <script>

   <!-- Ask user for the permission for the Bluetooth access -->

   navigator.bluetooth.requestDevice({filters: [{name: "Unique Name"}] });
   .then(device => { 
      log('> Name:             ' + device.name);
      log('> Id:               ' + device.id);
   }) 
   .catch(error => { console.log(error); });

 </script> 

</body>
</html>


#2

For most beacon-based use cases, Web Bluetooth is not yet viable. The primary Web Bluetooth spec was built with devices you pair/connect to in mind, e.g., controlling a Bluetooth-enabled drone from a web page. Users of the web site get a popup to select the device they want to pair with/connect to. So this won’t work well if you have e.g. 50 beacons deployed across a venue.

There’s a separate Web Bluetooth Scanning project going on that’s specifically targeted for the beacon-based use cases. It’s still in the very early stages though, and I don’t think any web browser implements it yet:

https://github.com/WebBluetoothCG/web-bluetooth/blob/master/implementation-status.md#scanning-api