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 526d3a7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ 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;
for &byte in self.payload_length.to_le_bytes().iter() {
checksum += byte as u16
}
for &byte in self.message_id.to_le_bytes().iter() {
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 526d3a7

Please sign in to comment.