From d46d66211c380f7a361bc6ba1521d491cd75c800 Mon Sep 17 00:00:00 2001 From: liclac Date: Sat, 1 Sep 2018 16:19:28 +0100 Subject: [PATCH] wifi dowsing rod --- dowsingrod/main.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 dowsingrod/main.py diff --git a/dowsingrod/main.py b/dowsingrod/main.py new file mode 100644 index 0000000..9612c76 --- /dev/null +++ b/dowsingrod/main.py @@ -0,0 +1,42 @@ +"""This is a dowsing rod for WiFi APs""" + +___name___ = "Dowsing Rod" +___license___ = "MIT" +___dependencies___ = ["sleep", "app", "wifi", "sim800"] +___categories___ = ["EMF", "System"] + +import ugfx, wifi, app +from tilda import Buttons +from time import sleep + +status_height = 20 + +ugfx.init() +ugfx.clear() +ugfx.set_default_font(ugfx.FONT_FIXED) + +ugfx.Label(5, 180, 240, 15, "Press A to scan, MENU to exit") + +# while (not Buttons.is_pressed(Buttons.BTN_A)) and (not Buttons.is_pressed(Buttons.BTN_B)) and (not Buttons.is_pressed(Buttons.BTN_Menu)): +while not Buttons.is_pressed(Buttons.BTN_Menu): + if not Buttons.is_pressed(Buttons.BTN_A): + sleep(0.1) + continue + + ugfx.clear() + + # networks = [{ "ssid": ap[0], "mac": ap[1], "channel": ap[2], "signal": ap[3] } for ap in wifi.nic().scan()] + networks = sorted([net for net in wifi.nic().scan() if net[0] == "emfcamp-legacy18"], key=lambda n: n[3], reverse=True) + + aps = [] + for ap in [(net[1], net[3]) for net in networks]: + if ap[0] not in [ap[0] for ap in aps]: + aps.append(ap) + + y = 0 + for ap in aps[:20]: + ugfx.Label(0, y, 240, 25, "{1}dB {0}".format(*ap)) + y += status_height + +ugfx.clear() +app.restart_to_default()