diff --git a/tests/test_responses.py b/tests/test_responses.py index 2202ce83..1ffeabb6 100644 --- a/tests/test_responses.py +++ b/tests/test_responses.py @@ -559,6 +559,16 @@ def test_response_004d(self): ]) ) + def test_response_8035(self): + msg_data = unhexlify(b'030000f104') + r = responses.R8035(msg_data, 255) + self.assertDictEqual(r.cleaned_data(), + OrderedDict([('status', 3), + ('record', 0x0000f104), + ('lqi', 255), + ])) + self.assertEqual(r.status_text(), 'E_PDM_SYSTEM_EVENT_LARGEST_RECORD_FULL_SAVE_NO_LONGER_POSSIBLE') + if __name__ == '__main__': unittest.main() diff --git a/zigate/core.py b/zigate/core.py index 75e47f33..3823de11 100644 --- a/zigate/core.py +++ b/zigate/core.py @@ -629,6 +629,8 @@ def interpret_response(self, response): continue device = Device(dict(d), self) self._set_device(device) + elif response.msg == 0x8035: # PDM event + LOGGER.warning('PDM Event : %s %s', response['status'], response.status_text()) elif response.msg == 0x8042: # node descriptor addr = response['addr'] d = self.get_device_from_addr(addr) diff --git a/zigate/responses.py b/zigate/responses.py index b3c54cc4..7bb5065f 100644 --- a/zigate/responses.py +++ b/zigate/responses.py @@ -453,6 +453,39 @@ class R8031(R8030): type = 'unBind response' +@register_response +class R8035(Response): + msg = 0x8035 + type = 'PDM Event' + s = OrderedDict([('status', 'B'), + ('record', 'I'), + ]) + + def status_text(self): + status_codes = ['E_PDM_SYSTEM_EVENT_WEAR_COUNT_TRIGGER_VALUE_REACHED', + 'E_PDM_SYSTEM_EVENT_DESCRIPTOR_SAVE_FAILED', + 'E_PDM_SYSTEM_EVENT_PDM_NOT_ENOUGH_SPACE', + 'E_PDM_SYSTEM_EVENT_LARGEST_RECORD_FULL_SAVE_NO_LONGER_POSSIBLE', + 'E_PDM_SYSTEM_EVENT_SEGMENT_DATA_CHECKSUM_FAIL', + 'E_PDM_SYSTEM_EVENT_SEGMENT_SAVE_OK', + 'E_PDM_SYSTEM_EVENT_EEPROM_SEGMENT_HEADER_REPAIRED', + 'E_PDM_SYSTEM_EVENT_SYSTEM_INTERNAL_BUFFER_WEAR_COUNT_SWAP', + 'E_PDM_SYSTEM_EVENT_SYSTEM_DUPLICATE_FILE_SEGMENT_DETECTED', + 'E_PDM_SYSTEM_EVENT_SYSTEM_ERROR', + 'E_PDM_SYSTEM_EVENT_SEGMENT_PREWRITE', + 'E_PDM_SYSTEM_EVENT_SEGMENT_POSTWRITE', + 'E_PDM_SYSTEM_EVENT_SEQUENCE_DUPLICATE_DETECTED', + 'E_PDM_SYSTEM_EVENT_SEQUENCE_VERIFY_FAIL', + 'E_PDM_SYSTEM_EVENT_PDM_SMART_SAVE', + 'E_PDM_SYSTEM_EVENT_PDM_FULL_SAVE', + ] + try: + return status_codes[self.data.get('status')] + except IndexError: + return 'Unknown PDM event' + + + @register_response class R8040(Response): msg = 0x8040 diff --git a/zigate/version.py b/zigate/version.py index fe6f298b..aaa7d3a3 100644 --- a/zigate/version.py +++ b/zigate/version.py @@ -6,4 +6,4 @@ # -__version__ = '0.40.6' +__version__ = '0.40.7'