diff options
author | Bjørn Mork <bjorn@mork.no> | 2019-05-11 16:48:47 +0200 |
---|---|---|
committer | Bjørn Mork <bjorn@mork.no> | 2019-05-11 16:48:47 +0200 |
commit | 35f58c6cb31983ea50e28d46128e00b5c8660976 (patch) | |
tree | 883fa8d9686e1a80ab72f2a3fc09720429409077 | |
parent | 8325e98c10232dacca6c1e2a8044b1a24ab34cf4 (diff) |
WiP: wifi network parsing
Signed-off-by: Bjørn Mork <bjorn@mork.no>
-rwxr-xr-x | dcs8000lh-configure.py | 20 |
1 files 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 + ")&" |