Created
January 11, 2016 16:05
-
-
Save janjongboom/ddda81a1f9693165fa30 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Web Bluetooth demo</title> | |
</head> | |
<body> | |
<button id="go">Go Bluetooth</button> | |
<script> | |
document.querySelector('#go').onclick = (e) => { | |
e.preventDefault(); | |
// Use the same service UUID as in mbed here! | |
navigator.bluetooth.requestDevice({ filters: [{ services: [ 0x8765 ] }] }) | |
.then(device => { | |
console.log('Found device ' + device.name); | |
return device.connectGATT(); | |
) | |
.then(() => | |
alert('Connected over GATT!'); | |
}); | |
.catch(err => { | |
alert('' + err + ' ' + JSON.stringify(err)); | |
}); | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment