diff --git a/esphome/components/espnow/espnow_packet.c b/esphome/components/espnow/espnow_packet.c index ba67b7ec8b..a8b5c77222 100644 --- a/esphome/components/espnow/espnow_packet.c +++ b/esphome/components/espnow/espnow_packet.c @@ -29,17 +29,17 @@ inline void ESPNowPacket::info(std::string place) { } bool ESPNowPacket::is_valid() { - uint16_t crc = random; + uint16_t crc = this->crc16; recalc(); bool valid = (std::memcmp(&header, &transport_header, 3) == 0); valid &= (this->app_id != 0); - valid &= (this->random == crc); + valid &= (this->crc16 == crc); if (!valid) { ESP_LOGV("Packet", "Invalid H:%02x%02x%02x A:%06x R:%02x C:%04x ipv. %04x, %d&%d&%d=%d\n", this->header[0], - this->header[1], this->header[2], this->app_id, this->ref_id, crc, this->random, - std::memcmp(&header, &transport_header, 3) == 0, (this->app_id != 0), (this->random == crc), valid); + this->header[1], this->header[2], this->app_id, this->ref_id, crc, this->crc16, + std::memcmp(&header, &transport_header, 3) == 0, (this->app_id != 0), (this->crc16 == crc), valid); } - this->random = crc; + this->crc16 = crc; return valid; } diff --git a/esphome/components/espnow/espnow_packet.h b/esphome/components/espnow/espnow_packet.h index 3dcd1a0130..380a808370 100644 --- a/esphome/components/espnow/espnow_packet.h +++ b/esphome/components/espnow/espnow_packet.h @@ -81,8 +81,8 @@ struct ESPNowPacket { } inline void recalc() { - random = 0; - random = esp_crc16_le(ref_id, (uint8_t *) &content, 10 + size); + crc16 = 0; + crc16 = esp_crc16_le(ref_id, (uint8_t *) &content, 10 + size); } bool is_valid();