scudre / alarm-central-station-receiver

Python daemon for receiving events from a home alarm system via Contact ID protocol
Apache License 2.0
38 stars 10 forks source link

Refactored code parsing to improve performance #28

Closed scudre closed 6 years ago

scudre commented 6 years ago

In some cases it seems that DTMF digits are not collected fast enough from the TigerJet fd. To simplify the logic, instead of attempting to collect the codes and calculate the checksum at the same time, it now will:

1) Collect the codes as a single large string 2) Hang up with the alarm system 3) Then use a regex to find all of the 15 or 16 length contact-id strings 4) Calculate the checksum per code

Also changed up how the checksum validation errors are handled. Previously if the checksum was invalid decoding of the contact ID string was not even attempted. Though it seems that in majority, if not all cases, where the checksum isn't valid the alarm string still may be. So now decoding of the DTMF string will always be attempted, and if the checksum is invalid, this will be appended to notification message.