JSFiddle - React, Tailwind, and code Playground
by lun471k
HTML
<button id="button">
Enable Bluetooth
</button>
JavaScript
var button = $('#button');
button.on('pointerup',function(event){
navigator.bluetooth.requestDevice({ filters: [{ services: ['heart_rate'] }] })
.then(device => { device.gatt.connect() })
.then(server => {
return server.getPrimaryService('heart_rate');
})
.then(characteristic => {
return characteristic.readValues();
})
.then(value => {
console.log('Heart rate is ' + value.getUint32(0));
})
.catch(error => { console.log(error); });
})