mirror of
https://github.com/esphome/esphome.git
synced 2024-12-28 08:21:44 +01:00
some CI linting fixes
This commit is contained in:
parent
8ea18de5a4
commit
f1c23c809c
2 changed files with 8 additions and 9 deletions
|
@ -40,7 +40,7 @@ std::string format_mac_addr(const uint8_t *mac) {
|
|||
return buf;
|
||||
}
|
||||
void show_packet(std::string title, ESPNowPacket *packet) {
|
||||
ESP_LOGVV(TAG, "%s packet: M:%s H:%cx%cx%c P:%c%c%c 0x%02x S:%02x C:ox%02x~0x%02x S:%02d V:%s", title.c_str(),
|
||||
ESP_LOGVV(TAG, "%s packet: M:%s H:%cx%cx%c P:%c%c%c 0x%02x S:%02x C:ox%02x~0x%02x S:%02d V:%s", title,
|
||||
format_mac_addr(packet->peer_as_bytes()).c_str(), packet->content_at(0), packet->content_at(1),
|
||||
packet->content_at(2), packet->content_at(3), packet->content_at(4), packet->content_at(5),
|
||||
packet->content_at(6), packet->content_at(7), packet->crc(), packet->calc_crc() packet->get_size(),
|
||||
|
@ -72,7 +72,7 @@ bool ESPNowPacket::is_valid() {
|
|||
uint16_t crc = this->content.payload[this->size];
|
||||
bool valid = (memcmp((const void *) &this->content, (const void *) &TRANSPORT_HEADER, 3) == 0);
|
||||
valid &= (this->get_protocol() != 0);
|
||||
valid &= (this->calc_crc_() == crc);
|
||||
valid &= (this->calc_crc() == crc);
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
|
|
@ -110,6 +110,11 @@ struct ESPNowPacket {
|
|||
// this->update_payload_();
|
||||
return this->content.payload[this->size];
|
||||
}
|
||||
uint8_t calc_crc() {
|
||||
uint8_t crc = esp_crc8_le(0, (const uint8_t *) &(this->content.protocol), 2);
|
||||
crc = esp_crc8_le(crc, this->peer_as_bytes(), 6);
|
||||
return esp_crc8_le(crc, (const uint8_t *) &this->content, this->size);
|
||||
}
|
||||
|
||||
void retry() { this->attempts++; }
|
||||
bool is_valid();
|
||||
|
@ -117,19 +122,13 @@ struct ESPNowPacket {
|
|||
private:
|
||||
ByteBuffer *payload_buffer_{nullptr};
|
||||
|
||||
uint8_t calc_crc_() {
|
||||
uint8_t crc = esp_crc8_le(0, (const uint8_t *) &(this->content.protocol), 2);
|
||||
crc = esp_crc8_le(crc, this->peer_as_bytes(), 6);
|
||||
return esp_crc8_le(crc, (const uint8_t *) &this->content, this->size);
|
||||
}
|
||||
|
||||
void update_payload_() {
|
||||
if (this->payload_buffer_->is_changed()) {
|
||||
this->payload_buffer_->flip();
|
||||
this->payload_buffer_->get_bytes((uint8_t *) &(this->content.payload), this->payload_buffer_->get_used_space());
|
||||
this->size = this->payload_buffer_->get_used_space() + this->prefix_size();
|
||||
}
|
||||
this->content.payload[this->size] = this->calc_crc_();
|
||||
this->content.payload[this->size] = this->calc_crc();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue