Getting physical with web bluetooth in the browser
-
Upload
dan-jenkins -
Category
Technology
-
view
309 -
download
2
Transcript of Getting physical with web bluetooth in the browser
@dan_jenkins
Android iOS• Location & Bluetooth turned on
• Android "Nearby" enabled (default)
https://android.googleblog.com/2016/06/introducing-nearby-new-way-to-discover.html
• Bluetooth turned on
• Chrome Notifications enabled
(Allow the Chrome widget in Notification Center)
https://docs.pushmote.com/docs/how-to-enable-chromes-physical-web-extension-on-the-ios
@dan_jenkins
Eddystone• Open Message Format
• A few different parts to Eddystone but all we care about here is Eddystone URL format
• Eddystone URLs have 18 bytes worth of data that can be broadcast
• Eddystone is supported by over 30 vendors
• Eddystone is also compatible with iBeacon
• https://developers.google.com/beacons/eddystone
@dan_jenkins
Chrome• Chrome on iOS and Nearby on Android scans for BLE beacons with
Eddystone URLs
• Chrome only supports HTTPS URLs
• Chrome then sends those URLs up to Google's Proxy service
(does some extra magic)
• The Proxy service then sends those URLs back to Chrome
• Chrome/Nearby shows a notification
So all of this doesn't work unless you have data!
@dan_jenkinshttp://www.proxama.com/news/proxama-partners-with-google-to-deliver-worlds-first-physical-web-experience-for-consumers/
@dan_jenkinshttp://www.proxama.com/news/proxama-partners-with-google-to-deliver-worlds-first-physical-web-experience-for-consumers/
@dan_jenkins
Stepping back, what is BLE?• Low Bandwidth
• Bluetooth v4 - Bluetooth Low Energy (0.3 Mbps) • Bluetooth v3 (54 Mbps)
• A set of Standard Services • But you can also build your own services
@dan_jenkins
BLE GATT ServerGatt Server
Custom ServiceBattery Service
Battery Level Characteristic
Custom Characteristic #1
Custom Characteristic #1
@dan_jenkins
var options = { filters: [{ services: ['heart_rate'] }] };
navigator.bluetooth.requestDevice(options) .then(device => device.gatt.connect()) .then(server => server.getPrimaryService('heart_rate')) .then(service => service.getCharacteristic('heart_rate_measurement')) .then(characteristic => { characteristic.addEventListener('characteristicvaluechanged', beep); return characteristic.startNotifications(); }) .catch(error => { console.log(error); });
function beep(event) { console.log(event.target.value); }
@dan_jenkins
var options = { filters: [{ services: ['heart_rate'] }] };
navigator.bluetooth.requestDevice(options) .then(device => device.gatt.connect()) .then(server => server.getPrimaryService('heart_rate')) .then(service => service.getCharacteristic('heart_rate_measurement')) .then(characteristic => { characteristic.addEventListener('characteristicvaluechanged', beep); return characteristic.startNotifications(); }) .catch(error => { console.log(error); });
function beep(event) { console.log(event.target.value); }
@dan_jenkins
var options = { filters: [{ services: ['heart_rate'] }] };
navigator.bluetooth.requestDevice(options) .then(device => device.gatt.connect()) .then(server => server.getPrimaryService('heart_rate')) .then(service => service.getCharacteristic('heart_rate_measurement')) .then(characteristic => { characteristic.addEventListener('characteristicvaluechanged', beep); return characteristic.startNotifications(); }) .catch(error => { console.log(error); });
function beep(event) { console.log(event.target.value); }
@dan_jenkins
var options = { filters: [{ services: ['heart_rate'] }] };
navigator.bluetooth.requestDevice(options) .then(device => device.gatt.connect()) .then(server => server.getPrimaryService('heart_rate')) .then(service => service.getCharacteristic('heart_rate_measurement')) .then(characteristic => { characteristic.addEventListener('characteristicvaluechanged', beep); return characteristic.startNotifications(); }) .catch(error => { console.log(error); });
function beep(event) { console.log(event.target.value); }
@dan_jenkins
var options = { filters: [{ services: ['heart_rate'] }] };
navigator.bluetooth.requestDevice(options) .then(device => device.gatt.connect()) .then(server => server.getPrimaryService('heart_rate')) .then(service => service.getCharacteristic('heart_rate_measurement')) .then(characteristic => { characteristic.addEventListener('characteristicvaluechanged', beep); return characteristic.startNotifications(); }) .catch(error => { console.log(error); });
function beep(event) { console.log(event.target.value); }
@dan_jenkins
var options = { filters: [{ services: ['heart_rate'] }] };
navigator.bluetooth.requestDevice(options) .then(device => device.gatt.connect()) .then(server => server.getPrimaryService('heart_rate')) .then(service => service.getCharacteristic('heart_rate_measurement')) .then(characteristic => { characteristic.addEventListener('characteristicvaluechanged', beep); return characteristic.startNotifications(); }) .catch(error => { console.log(error); });
function beep(event) { console.log(event.target.value); }
@dan_jenkins
var options = { filters: [{ services: ['heart_rate'] }] };
navigator.bluetooth.requestDevice(options) .then(device => device.gatt.connect()) .then(server => server.getPrimaryService('heart_rate')) .then(service => service.getCharacteristic('heart_rate_measurement')) .then(characteristic => { characteristic.addEventListener('characteristicvaluechanged', boop); return characteristic.startNotifications(); }) .catch(error => { console.log(error); });
function boop(event) { console.log(event.target.value); }
@dan_jenkins
var options = { filters: [{ services: ['heart_rate'] }] };
navigator.bluetooth.requestDevice(options) .then(device => device.gatt.connect()) .then(server => server.getPrimaryService('heart_rate')) .then(service => service.getCharacteristic('heart_rate_measurement')) .then(characteristic => { characteristic.addEventListener('characteristicvaluechanged', beep); return characteristic.startNotifications(); }) .catch(error => { console.log(error); });
function beep(event) { console.log(event.target.value); }
@dan_jenkins
var options = { filters: [{ services: ['heart_rate'] }] };
navigator.bluetooth.requestDevice(options) .then(device => device.gatt.connect()) .then(server => server.getPrimaryService('heart_rate')) .then(service => service.getCharacteristic('heart_rate_measurement')) .then(characteristic => { characteristic.addEventListener('characteristicvaluechanged', beep); return characteristic.startNotifications(); }) .catch(error => { console.log(error); });
function beep(event) { console.log(event.target.value); }
@dan_jenkins
But that's changing soon toovar referringDevice = navigator.bluetooth.referringDevice;
if (referringDevice) { referringDevice.gatt.connect() .then(server => { ... }) .catch(error => { console.log(error); }); }
@dan_jenkins
But that's changing soon toovar referringDevice = navigator.bluetooth.referringDevice;
if (referringDevice) { referringDevice.gatt.connect() .then(server => { ... }) .catch(error => { console.log(error); }); }
@dan_jenkins
Where can I play with Web Bluetooth today?
In short.... Chrome/Chromium on...
Android M & N ChromeOS Linux
Android L with Chromium
OSX (Chrome 53)
@dan_jenkins
But for more info...
https://github.com/WebBluetoothCG/web-bluetooth/blob/gh-pages/implementation-status.md
@dan_jenkins
Physical Web & Web Bluetooth
Some beacons now run a GATT server inside them
They run a "Eddystone URL Configuration Service"