Blog‎ > ‎

Chrome, JavaScript and The Physical Web: "Interact with BLE devices on the Web"

pubblicato 23 nov 2015, 13:45 da iBlio connect   [ aggiornato in data 23 gen 2016, 02:33 ]
Google showed off some of its recent work enabling the “Physical Web.” Bluetooth-LE is the enabling technology that will link browsers and the internet to physical objects and the things near you.

Bluetooth-LE (“low-energy”) was introduced around 2011. It brings interesting new features that were not in “Bluetooth Classic.” Beacon functionality was added so that devices can advertise their existence.  B-LE devices do not require the complex pairing operations that Classic devices need. B-LE makes it easier to simply take control of devices that are physically near you.

Google Chrome now has experimental support for Javascript methods to access Bluetooth. This has been in the developer channel for a little while, but it is now available in the general release for desktop and Android.  Chrome for iOS had previously announced support, so there is no change there. Chrome on desktop platforms requires you to enable the feature under chrome://flags#enable-web-bluetooth.

Once you do, you’ll be able to construct a website that uses Bluetooth to control a nearby object. Javascript in the webpage can access thenavigator.bluetooth.requestDevice method to look for a particular type of device, or a device advertising a particular service. (Note: the Chrome implementation does not allow code to obtain a list of every nearby device, as the developers view this a security risk.) A webpage may, however, look for a particular device given its UUID – a globally unique identifier.

By enabling the browser with Bluetooth access, a website can dynamically load and execute a Javascript program particular to a certain type of device. Get near a dimmable light-bulb, and it will advertise a web page that lets you control it. The web page and the Javascript are delivered over the web, but the control of the light will be direct from your laptop to the lightbulb. Step up to a parking meter, and a web-page will accept your payment already knowing which meter you’re near.  The payment will be handled by Stripe on a web site, and your device will be able to charge the meter directly over Bluetooth.

Read More

Check out a Code Lab