sm300d2: Accept (undocumented) 0x80 checksum offset. (#2263)

Co-authored-by: Matt Hallacy <github@poptix.net>
This commit is contained in:
poptix 2021-09-10 04:05:25 -05:00 committed by Jesse Hills
parent 7dd40e2014
commit 87842e097b
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A

View file

@ -27,7 +27,8 @@ void SM300D2Sensor::update() {
}
uint16_t calculated_checksum = this->sm300d2_checksum_(response);
if (calculated_checksum != response[SM300D2_RESPONSE_LENGTH - 1]) {
if ((calculated_checksum != response[SM300D2_RESPONSE_LENGTH - 1]) &&
(calculated_checksum - 0x80 != response[SM300D2_RESPONSE_LENGTH - 1])) {
ESP_LOGW(TAG, "SM300D2 Checksum doesn't match: 0x%02X!=0x%02X", response[SM300D2_RESPONSE_LENGTH - 1],
calculated_checksum);
this->status_set_warning();