Skip to content

Instantly share code, notes, and snippets.

@janjongboom
Created January 11, 2016 16:05
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janjongboom/ddda81a1f9693165fa30 to your computer and use it in GitHub Desktop.
Save janjongboom/ddda81a1f9693165fa30 to your computer and use it in GitHub Desktop.
<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