diff --git a/pyad2usb/ad2usb.py b/pyad2usb/ad2usb.py index 2ef526c..3dbde7a 100644 --- a/pyad2usb/ad2usb.py +++ b/pyad2usb/ad2usb.py @@ -154,6 +154,7 @@ class AD2USB(object): on_power_changed = event.Event('Called when panel power switches between AC and DC.') on_alarm = event.Event('Called when the alarm is triggered.') on_bypass = event.Event('Called when a zone is bypassed.') + on_boot = event.Event('Called when the device finishes bootings.') # Mid-level Events on_message = event.Event('Called when a message has been received from the device.') @@ -189,6 +190,12 @@ class AD2USB(object): self._device.close() self._device = None + def reboot(self): + """ + Reboots the device. + """ + self._device.write('=') + @property def id(self): return self._device.id @@ -224,6 +231,8 @@ class AD2USB(object): msg = ExpanderMessage(data) elif header == '!RFX': msg = RFMessage(data) + elif data.startswith('!Ready'): + self.on_boot() return msg diff --git a/test.py b/test.py index 8ed297d..66fcbde 100755 --- a/test.py +++ b/test.py @@ -71,6 +71,9 @@ def handle_firmware(stage): elif stage == pyad2usb.ad2usb.util.Firmware.STAGE_DONE: print "\r\nDone!" +def handle_boot(sender, args): + print 'boot', args + def upload_usb(): dev = pyad2usb.ad2usb.devices.USBDevice() @@ -211,8 +214,10 @@ def test_socket(): a2u.on_power_changed += handle_power_changed a2u.on_alarm += handle_alarm_bell a2u.on_bypass += handle_bypass + a2u.on_boot += handle_boot a2u.open() + a2u.reboot() print dev._id