RafaelKa / node-serialport-enocean-parser

ESP3 parser for nodes serialport
Do What The F*ck You Want To Public License
6 stars 2 forks source link

fix issue with optionaldata awaited when none in the telegram #5

Closed codlab closed 7 years ago

codlab commented 7 years ago

This PR fixes the machine state improper state when an EnOcean packet is received with header.optionalLength = 0

in this case, fillOptionalData was called and pushed the byte into its array. This byte was actually the final data+optional data crc. Hence, "locking" the data into awaiting the crc. It would then require to receive a frame from an EnOcean compatible device to "flush" (and lose) the buffer.

The proposed PR fixes it by branching into the correct step when dealing with optional data

RafaelKa commented 7 years ago

@codlab Thanks for your PR, I changed it a little bit, please do not be angry about that.