Skip to content

Instantly share code, notes, and snippets.

@qdot
Created November 15, 2016 05:43
Show Gist options
  • Save qdot/86ff28790bd7cfcf4e4d854829b7dd79 to your computer and use it in GitHub Desktop.
Save qdot/86ff28790bd7cfcf4e4d854829b7dd79 to your computer and use it in GitHub Desktop.
navigator.bluetooth.requestDevice({filters: [{ services: ['6e400001-b5a3-f393-e0a9-e50e24dcca9e']}]}).then((device) => { d = device });
d.gatt.connect().then(server => s = server).catch(er => { console.log(er) });
s.getPrimaryService('6e400001-b5a3-f393-e0a9-e50e24dcca9e').then(service => ser = service);
ser.getCharacteristic('6e400002-b5a3-f393-e0a9-e50e24dcca9e').then(char => c = char);
c.writeValue(new TextEncoder('ASCII').encode("Vibrate:20;")).then(l => console.log("sent!")).catch(e => console.log(e));
c.writeValue(new TextEncoder('ASCII').encode("Vibrate:0;")).then(l => console.log("sent!")).catch(e => console.log(e));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment