forked from FOSS/BangleApps
Add BLE scanner app
parent
35c54b7097
commit
5600d3e24d
|
@ -0,0 +1 @@
|
|||
0.01: New App!
|
|
@ -0,0 +1 @@
|
|||
require("heatshrink").decompress(atob("mEwwhC/AH4ARkQAHBwsBiIACiAHBgQXIkAXJiIuKGAwWEC4cjmYABn//AAMyC63yC653FC6HwC5aQBC5ybIC44WChGAWxMgC44rCxGIZxYXFIoYXBGAQNCAAQXILYYXBGAUDBoK0EC5AsBC4QwEC5wAEC853BhAWDI6CPCFwp3OX4ouCC8xHXCAJ3VX94XCwBHVGIiPTU4oNCAAQWBX5gDBgQRCAAoXGGAUIFwQXHkAXHJIgABCw4IBC5sAiIAEiAgHAAQXLHBAYIC+6wJQYIADgIXGGBJ3FC4iOBAH4A/ACAA=="))
|
|
@ -0,0 +1,41 @@
|
|||
E.showMessage("Scanning...");
|
||||
var devices = [];
|
||||
|
||||
setInterval(function() {
|
||||
NRF.findDevices(function(devs) {
|
||||
devs.forEach(dev=>{
|
||||
var existing = devices.find(d=>d.id==dev.id);
|
||||
if (existing) {
|
||||
existing.timeout = 0;
|
||||
existing.rssi = (existing.rssi*3 + dev.rssi)/4;
|
||||
} else {
|
||||
dev.timeout = 0;
|
||||
dev.new = 0;
|
||||
devices.push(dev);
|
||||
}
|
||||
});
|
||||
devices.forEach(d=>{d.timeout++;d.new++});
|
||||
devices = devices.filter(dev=>dev.timeout<8);
|
||||
devices.sort((a,b)=>b.rssi - a.rssi);
|
||||
g.clear(1).setFont("12x20");
|
||||
var wasNew = false;
|
||||
devices.forEach((d,y)=>{
|
||||
y*=20;
|
||||
var n = d.name;
|
||||
if (!n) n=d.id.substr(0,22);
|
||||
if (d.new<4) {
|
||||
g.fillRect(0,y,g.getWidth(),y+19);
|
||||
g.setColor(g.theme.bg);
|
||||
if (d.rssi > -70) wasNew = true;
|
||||
} else {
|
||||
g.setColor(g.theme.fg);
|
||||
}
|
||||
g.setFontAlign(-1,-1);
|
||||
g.drawString(n,0,y);
|
||||
g.setFontAlign(1,-1);
|
||||
g.drawString(0|d.rssi,g.getWidth()-1,y);
|
||||
});
|
||||
g.flip();
|
||||
Bangle.setLCDBrightness(wasNew);
|
||||
}, 1200);
|
||||
}, 1500);
|
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
|
@ -0,0 +1,14 @@
|
|||
{ "id": "blescanner",
|
||||
"name": "BLE Scanner",
|
||||
"shortName":"BLE Scan",
|
||||
"version":"0.01",
|
||||
"description": "Scans for bluetooth devices nearby and shows their names on the screen ordered by signal strength. The most recently discovered items are highlighted.",
|
||||
"icon": "app.png",
|
||||
"screenshots" : [ { "url":"screenshot.png" } ],
|
||||
"tags": "tool,bluetooth",
|
||||
"supports" : ["BANGLEJS2"],
|
||||
"storage": [
|
||||
{"name":"blescanner.app.js","url":"app.js"},
|
||||
{"name":"blescanner.img","url":"app-icon.js","evaluate":true}
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
Loading…
Reference in New Issue