From f1c23c809c8a1a8d97d159fa4ca92a102da56375 Mon Sep 17 00:00:00 2001 From: NP v/d Spek Date: Sun, 22 Sep 2024 23:45:29 +0200 Subject: [PATCH] some CI linting fixes --- esphome/components/espnow/espnow.cpp | 4 ++-- esphome/components/espnow/espnow.h | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/esphome/components/espnow/espnow.cpp b/esphome/components/espnow/espnow.cpp index 51e555e66b..65297a5504 100644 --- a/esphome/components/espnow/espnow.cpp +++ b/esphome/components/espnow/espnow.cpp @@ -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; } diff --git a/esphome/components/espnow/espnow.h b/esphome/components/espnow/espnow.h index 1d643ae7ac..6af535af6d 100644 --- a/esphome/components/espnow/espnow.h +++ b/esphome/components/espnow/espnow.h @@ -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(); } };