Skip to content

Commit

Permalink
src: decoder: Fix: Skip to final step if payload lenght is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
RaulTrombin authored and patrickelectric committed Apr 3, 2024
1 parent 5deb5c3 commit e01764d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ impl Decoder {
self.message.message_id = u16::from_le_bytes([self.buffer[2], self.buffer[3]]);
self.message.src_device_id = self.buffer[4];
self.message.dst_device_id = self.buffer[5];
self.state = DecoderState::ReadingPayload;

if self.message.payload_length == 0 {
self.state = DecoderState::ReadingChecksum
} else {
self.state = DecoderState::ReadingPayload;
}
self.buffer.clear();
}
return DecoderResult::InProgress;
Expand Down

0 comments on commit e01764d

Please sign in to comment.