Skip to content

Instantly share code, notes, and snippets.

@bwhite
Created April 18, 2014 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bwhite/11062895 to your computer and use it in GitHub Desktop.
Save bwhite/11062895 to your computer and use it in GitHub Desktop.
[wearscript] Bluetooth Discover/Bond
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<script>
function cb(data) {
WS.log(data);
data = JSON.parse(data);
var addr = "54:46:6B:00:A6:BD";
if (data.address == addr) {
WSRAW.bluetoothBond(addr, "1234");
WS.say('bonding')
}
}
function main() {
if (WS.scriptVersion(1)) return;
WS.bluetoothList(function (x) {
WS.log(JSON.stringify(x))
})
WS.bluetoothRead("54:46:6B:00:A6:BD", function (x) {
WS.log(x)
});
return;
WSRAW.bluetoothDiscover('cb')
WS.gestureCallback('onGestureSWIPE_LEFT', function () {
WS.bluetoothWrite("00:14:01:17:16:63", '0');
});
WS.gestureCallback('onGestureSWIPE_RIGHT', function () {
WS.bluetoothWrite("00:14:01:17:16:63", '1');
});
}
window.onload = main;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment