Skip to content

Instantly share code, notes, and snippets.

@thangman22
Created October 30, 2016 04:17
Show Gist options
  • Save thangman22/616dd0d152c9414c437e6436f91aec0b to your computer and use it in GitHub Desktop.
Save thangman22/616dd0d152c9414c437e6436f91aec0b to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title></title>
<script>
function onButtonClick() {
let filters = [];
filters.push({services: ['battery_service']});
navigator.bluetooth.requestDevice({filters: filters})
.then(device => {
console.log(device)
})
.catch(error => {
console.log('Argh! ' + error);
});
}
</script>
</head>
<body>
<button onclick="onButtonClick()">Connect</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment