mcw0 / DahuaConsole

Dahua Console, access internal debug console and/or other researched functions in Dahua devices. Feel free to contribute in this project.
MIT License
247 stars 72 forks source link

global.getCurrentTime does not exist on every camera, crashing program #4

Closed LukaszMoskala closed 3 years ago

LukaszMoskala commented 3 years ago

Hi,

Just to let you (and anyone else who may have the same problem) know, on line 490 of net.py there is:

dh_data.get('global.getCurrentTime').get('params').get('time'),

This is not working with my camera. Maybe because mine firmware is from 2014.

So anyway, I changed:

        log.info("Remote Model: {}, Class: {}, Time: {}".format(
            self.DeviceType,
            self.DeviceClass,
            dh_data.get('global.getCurrentTime').get('params').get('time'),
        ))

To:

        log.info("Remote Model: {}, Class: {}".format(
            self.DeviceType,
            self.DeviceClass
        ))

And it's working. I'd open pull request for that, but it's already late for me. You can change this in your code if you want.

mcw0 commented 3 years ago

Cool, many thanks, will try to fix that with 'if' statement so it will not crash.

BTW, you may want to add "magic":"0x1234" to all outgoing JSON requests with DHIP protocol, w/o that DHIP will most probably not work with your old Firmware.