Add BLE Scanner app

pull/16/head
Shane T Odlum 2019-11-11 16:59:02 +00:00
parent 80d88200c1
commit 953ee0471b
5 changed files with 72 additions and 0 deletions

View File

@ -337,5 +337,17 @@
{"name":".tfmodel","url":"gesture-tfmodel.js","evaluate":true},
{"name":"*gesture","url":"gesture-icon.js","evaluate":true}
]
},
{
"id": "blescan",
"name": "BLE Scanner",
"icon": "blescan.png",
"description": "Scan for advertising BLE devices",
"tags" : "bluetooth",
"storage" : [
{"name":"+blescan","url":"blescan.json"},
{"name":"-blescan","url":"blescan.js"},
{"name":"*blescan","url":"blescan-icon.js", "evaluate":true}
]
}
]

1
apps/blescan-icon.js Normal file
View File

@ -0,0 +1 @@
var img = require("heatshrink").decompress(atob("mEwxH+AH4A/AH4ATmIABrdbAgQrmAAYvEAAYtkF5QxcEZAvLGDAhJF5oxWFhYAFCBFaFzQsHAAk3CQmE1wwRFxiPFMY4uBwiSRI4uEQo4GIAAIVBxTCRFwoABJITvNrYTHRqIuCAAIvPxQSBBQwvQL6aMCBQ7sQVIQuGdIjqIGCIOEm4XHForqFIAYHBm4vTFxYMDAQKeHDIwvVRAoEDdRAvPE5QcHAoTqJDQ5eZAwS7DIZovWAodaRQLqGF6bhDABouCXYIAQF+6PUrQUQd7oMKF6wbLApYaIF45gSAgxeUF5olDBIICECJIvTm4wLAAoPHm4vTC4OK12EGJYLFI5IvJGAuE1wABGAycIBRQuKF4ouCAAIvPIgOFF6QwEL6c3IRAuMGA+EWw4GIwuusAuTeQzqGF4r0LF6AwIm4mEAA03FzAwJLAxbKFygwLd5IuaMRwthGBYvKFzQxJF5AtdGZAvEFcYA/AH4AvA=="))

52
apps/blescan.js Normal file
View File

@ -0,0 +1,52 @@
// ble-scanner
// Scan the airwaves every three seconds (which seems safe for a large number of devices)
// Using the menu feature, display a scrollable list of BLE devices on the watch
// Dummy menu item to display until we find something
const NODEVICE = 'No devices found';
const SCAN_INTERVAL = 3000;
const menu = {
};
menu[NODEVICE] = {
value : "",
onchange : () => {}
};
function draw() {
Bangle.menu(menu);
}
function scan() {
NRF.findDevices(devices => {
for (let device of devices) {
// Only display devices that advertise a name
if (device.name) {
// Remove no devices found message if it is present
if (menu[NODEVICE]) {
delete menu[NODEVICE];
}
menu[device.name] = {
value : device.rssi,
onchange : () => {}
};
}
}
draw();
}, { active: true });
}
function waitMessage() {
E.showMessage('scanning');
}
scan();
waitMessage();
setInterval(scan, SCAN_INTERVAL);

7
apps/blescan.json Normal file
View File

@ -0,0 +1,7 @@
{
"name": "BLE Scanner",
"type":"app",
"icon": "*blescan",
"src": "-blescan"
}

BIN
apps/blescan.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB