Skip to content

Commit

Permalink
src: message: Fix: Checksum split payload_lenght and msg_id into two …
Browse files Browse the repository at this point in the history
…bytes
  • Loading branch information
RaulTrombin committed Apr 4, 2024
1 parent e01764d commit 19283de
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,14 @@ impl ProtocolMessage {
let mut checksum: u16 = 0;
checksum += HEADER[0] as u16;
checksum += HEADER[1] as u16;
checksum += self.payload_length;
checksum += self.message_id;
self.payload_length
.to_le_bytes()
.iter()
.for_each(|byte| checksum += *byte as u16);
self.message_id
.to_le_bytes()
.iter()
.for_each(|byte| checksum += *byte as u16);
checksum += self.src_device_id as u16;
checksum += self.dst_device_id as u16;
for &byte in &self.payload {
Expand Down

0 comments on commit 19283de

Please sign in to comment.