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 1985692
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ 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;
let (msb, lsb) = ((self.payload_length >> 8) as u8, self.payload_length as u8);
checksum += msb as u16 + lsb as u16;
let (msb, lsb) = ((self.message_id >> 8) as u8, self.message_id as u8);
checksum += msb as u16 + lsb 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 1985692

Please sign in to comment.