Skip to content

Commit

Permalink
prioritise checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
GLinnik21 committed Aug 25, 2023
1 parent 33d584e commit 38a2609
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/mh_z19_uart_tools/mh_z19_uart_tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ void mh_z19_uart_switch_detection_range(MhZ19DetectionRange range, uint8_t* comm
}

int16_t mh_z19_decode_co2_concentration(const uint8_t* data) {
if(data[1] != MhZ19UartCommandCO2Concentraion) {
return -1; // Invalid command
}
if(data[8] != mh_z19_uart_checksum(data)) {
return -2; // Invalid checksum
}
if(data[1] != MhZ19UartCommandCO2Concentraion) {
return -1; // Invalid command
}
return (data[2] << 8) | data[3];
}

0 comments on commit 38a2609

Please sign in to comment.