From 35f58c6cb31983ea50e28d46128e00b5c8660976 Mon Sep 17 00:00:00 2001 From: Bjørn Mork Date: Sat, 11 May 2019 16:48:47 +0200 Subject: WiP: wifi network parsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bjørn Mork --- dcs8000lh-configure.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/dcs8000lh-configure.py b/dcs8000lh-configure.py index f57e4db..6dda245 100755 --- a/dcs8000lh-configure.py +++ b/dcs8000lh-configure.py @@ -27,7 +27,6 @@ class BleCam(object): for h in handles: print("%s - Handle=%#06x (%s)" % (h.uuid, h.getHandle(), h.propertiesToString())) - def unlock(self): auth = self.service.getCharacteristics(0xa001)[0] for t in auth.read().decode().split(";", 10): @@ -43,7 +42,24 @@ class BleCam(object): def get_ipconfig(self): return self.service.getCharacteristics(0xa104)[0].read() + def wifi_scan(self): + + def _wifi_network(netstr): + keymap = { + "I": "essid", + "M": "authalg", # ?? + "C": "channel", + "S": "key_mgmt", # ?? /auth_alg/proto? + "E": "proto", # ?? + "P": "rssi", # ?? + } + result = {} + for x in netstr[2:].split(",", 10): + (k, v) = x.split("=", 2) + result[keymap[k]] = v + return result + scan = self.service.getCharacteristics(0xa100)[0] p = -1 n = 0 @@ -56,7 +72,7 @@ class BleCam(object): n = int(t[0].split("=",2)[1]) p = int(t[1].split("=",2)[1]) print("read page %d of %d" % (p, n)) - return result.split("&", 50) + return map(_wifi_network, result.split("&", 50)) def run_command(self, command): run = "P=" + self.pincode + ";N=" + self.pincode + "&&(" + command + ")&" -- cgit v1.2.3