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 GitHub
parent affaaf7d2c
commit 3d71e2e189
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

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();