From bb5cdf5d4cceb48897619d173b33908c976eeb95 Mon Sep 17 00:00:00 2001 From: Bjørn Mork Date: Sun, 12 May 2019 21:30:29 +0200 Subject: WiP: fix initial pw setting and HTTPServer enabling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bjørn Mork --- dcs8000lh-configure.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/dcs8000lh-configure.py b/dcs8000lh-configure.py index fff7e9d..316cf9e 100755 --- a/dcs8000lh-configure.py +++ b/dcs8000lh-configure.py @@ -68,12 +68,15 @@ class BleCam(object): if not self.unlock(): return return kv2dict(self.service.getCharacteristics(0xa104)[0].read().decode()) + def sysinfo(self): + if not self.unlock(): return + return kv2dict(self.service.getCharacteristics(0xa200)[0].read().decode()) + def setup_wifi(self, essid, passwd): for net in self.wifi_scan(): if net["I"] == essid: cfg = "M=" + net["M"] + ";I=" + essid + ";S=" + net["S"] + ";E=" + net["E"] + ";K=" + passwd print("Will configure: %s" % cfg) - return True self.service.getCharacteristics(0xa101)[0].write(cfg.encode(), True) self.service.getCharacteristics(0xa102)[0].write("C=1".encode(), True) return True @@ -102,6 +105,7 @@ class BleCam(object): def run_command(self, command): if not self.unlock(): return + run = "P=" + self.pincode + ";N=" + self.pincode + "&&(" + command + ")&" if len(run) > 128: print("ERROR: command is too long") @@ -110,8 +114,13 @@ class BleCam(object): try: self.service.getCharacteristics(0xa201)[0].write(run.encode(), True) except: - print("ERROR: Failed - is the admin password different from the pincode?") - + # try repeating with an empty password, which seems to be te initial state after factory reset + run = "P=;N=" + self.pincode + "&&(" + command + ")&" + try: + self.service.getCharacteristics(0xa201)[0].write(run.encode(), True) + except: + print("ERROR: Failed - is the admin password different from the pincode?") + if __name__ == '__main__': parser = argparse.ArgumentParser(description="IPCam Bluetooth configuration tool.") parser.add_argument("address", help="IPCam Bluetooth MAC address (01:23:45:67:89:AB)") @@ -121,6 +130,7 @@ if __name__ == '__main__': parser.add_argument("--wifipw", help="Password for ESSID") parser.add_argument("--survey", help="List WiFi networks seen by the IPCam", action="store_true") parser.add_argument("--ipconfig", help="Print current IP configuration", action="store_true") + parser.add_argument("--sysinfo", help="Dump system configuration", action="store_true") parser.add_argument("--command", help="Run command on IPCam") parser.add_argument("--telnetd", help="Start telnet server on IPCam", action="store_true") parser.add_argument("--lighttpd", help="Start web server on IPCam", action="store_true") @@ -134,6 +144,8 @@ if __name__ == '__main__': wifiok = cam.setup_wifi(args.essid, args.wifipw) if args.ipconfig: print("ip config is: %s" % cam.get_ipconfig()) + if args.sysinfo: + print(cam.sysinfo()) if args.survey: for network in cam.wifi_scan(): print(network) @@ -147,6 +159,7 @@ if __name__ == '__main__': print("Starting telnetd") cam.run_command("pidof telnetd||telnetd") if args.lighttpd: + cam.run_command("[ $(tdb get HTTPServer Enable_byte) -eq 1 ] || tdb set HTTPServer Enable_byte=1") cam.run_command("/etc/rc.d/init.d/extra_lighttpd.sh start") if args.unsignedfw: cam.run_command("tdb set SecureFW _TrustLevel_byte=0") -- cgit v1.2.3