Merge branch 'master' into apps/pparrot

pull/17/head
Gordon Williams 2019-11-11 18:12:08 +00:00 committed by GitHub
commit 834b4d8485
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 70 additions and 0 deletions

View File

@ -348,6 +348,16 @@
{"name":"+pparrot","url":"party-parrot.json"},
{"name":"-pparrot","url":"party-parrot.js"},
{"name":"*pparrot","url":"party-parrot-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 @@
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