mirror of
https://github.com/esphome/esphome.git
synced 2024-12-18 19:44:53 +01:00
not all random value names where changed into crc16
This commit is contained in:
parent
7c6475de69
commit
57d3d8319b
2 changed files with 7 additions and 7 deletions
|
@ -29,17 +29,17 @@ inline void ESPNowPacket::info(std::string place) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ESPNowPacket::is_valid() {
|
bool ESPNowPacket::is_valid() {
|
||||||
uint16_t crc = random;
|
uint16_t crc = this->crc16;
|
||||||
recalc();
|
recalc();
|
||||||
bool valid = (std::memcmp(&header, &transport_header, 3) == 0);
|
bool valid = (std::memcmp(&header, &transport_header, 3) == 0);
|
||||||
valid &= (this->app_id != 0);
|
valid &= (this->app_id != 0);
|
||||||
valid &= (this->random == crc);
|
valid &= (this->crc16 == crc);
|
||||||
if (!valid) {
|
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],
|
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,
|
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->random == crc), valid);
|
std::memcmp(&header, &transport_header, 3) == 0, (this->app_id != 0), (this->crc16 == crc), valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->random = crc;
|
this->crc16 = crc;
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,8 @@ struct ESPNowPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void recalc() {
|
inline void recalc() {
|
||||||
random = 0;
|
crc16 = 0;
|
||||||
random = esp_crc16_le(ref_id, (uint8_t *) &content, 10 + size);
|
crc16 = esp_crc16_le(ref_id, (uint8_t *) &content, 10 + size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_valid();
|
bool is_valid();
|
||||||
|
|
Loading…
Reference in a new issue