Skip to content

Instantly share code, notes, and snippets.

@connerbrooks
Created April 11, 2014 01:42
Show Gist options
  • Save connerbrooks/10436559 to your computer and use it in GitHub Desktop.
Save connerbrooks/10436559 to your computer and use it in GitHub Desktop.
[wearscript] Wifi Data Collection
<html style="width:100%; height:100%; overflow:hidden">
<head>
</head>
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<canvas id="canvas" width="640" height="360" style="display:block"></canvas>
<script>
var wifiTree;
function updateTree() {
WS.cardTree(wifiTree);
WS.displayCardTree();
}
function server() {
WS.log('Welcome to WearScript');
WS.say('Wifi Data Tests');
WS.sound('SUCCESS')
var taps = 1;
WS.wifiOn(function (results) {
WS.log(JSON.stringify(results[0]));
for(var i = 0; i < results.length; i++) {
var bssid = results[i]['BSSID'];
var ssid = results[i]['SSID'];
var freq = results[i]['frequency'];
var level = results[i]['level'];
var datapoint = 'mac: ' + bssid + '\nssid: ' + ssid + '\nfreq: ' + freq + '\nlevel: ' + level;
wifiTree.add(datapoint, 'sweet');
}
updateTree();
});
wifiTree = new WS.Cards();
wifiTree.add('Wifi Data tap to add data point',
'swipe right to see data',
function () {},
function () {WS.wifiScan(); WS.say("Scanning")});
updateTree();
}
function main() {
if (WS.scriptVersion(1)) return;
ctx = document.getElementById('canvas').getContext("2d");
WS.serverConnect('{{WSUrl}}', server);
}
window.onload = main;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment