some CI linting fixes

This commit is contained in:
NP v/d Spek 2024-09-23 01:21:08 +02:00
parent c7fd70b1b0
commit 2581f858ed
2 changed files with 13 additions and 12 deletions

View file

@ -39,8 +39,8 @@ std::string format_mac_addr(const uint8_t *mac) {
sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
return buf;
}
void show_packet(char *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,
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", "test",
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(),
@ -49,7 +49,7 @@ void show_packet(char *title, ESPNowPacket *packet) {
/* ESPNowPacket ********************************************************************** */
ESPNowPacket::ESPNowPacket(uint64_t peer, const uint8_t *data, uint8_t size, uint32_t protocol) {
ESPNowPacket::ESPNowPacket(uint64_t peer, const uint8_t *data, uint8_t size, uint32_t protocol) : ESPNowPacket() {
this->set_peer(peer);
this->is_broadcast =
@ -59,7 +59,7 @@ ESPNowPacket::ESPNowPacket(uint64_t peer, const uint8_t *data, uint8_t size, uin
this->update_payload_();
}
ESPNowPacket::ESPNowPacket(uint64_t peer, const uint8_t *data, uint8_t size) {
ESPNowPacket::ESPNowPacket(uint64_t peer, const uint8_t *data, uint8_t size) : ESPNowPacket() {
this->set_peer(peer);
std::memcpy(&(this->content), data, this->prefix_size());
size -= this->prefix_size();

View file

@ -50,8 +50,7 @@ struct ESPNowPacket {
uint8_t payload[MAX_ESPNOW_DATA_SIZE + 2]{0};
} __attribute__((packed)) content;
ESPNowPacket(){};
~ESPNowPacket(){};
ESPNowPacket() { this->payload_buffer_ = make_unique(new ByteBuffer(MAX_ESPNOW_DATA_SIZE)); };
// Create packet to be send.
ESPNowPacket(uint64_t peer, const uint8_t *data, uint8_t size, uint32_t protocol);
@ -59,6 +58,8 @@ struct ESPNowPacket {
// Load received packet's.
ESPNowPacket(uint64_t peer, const uint8_t *data, uint8_t size);
~ESPNowPacket() { delete this->payload_buffer_; }
uint8_t *peer_as_bytes() { return (uint8_t *) &(this->peer); }
void set_peer(uint64_t peer) {
if (peer == 0) {
@ -88,7 +89,7 @@ struct ESPNowPacket {
}
ByteBuffer *payload() {
this->payload_buffer_.set_position(this->payload_buffer_.get_used_space());
this->payload_buffer_->set_position(this->payload_buffer_->get_used_space());
return this->payload_buffer_;
}
@ -117,13 +118,13 @@ struct ESPNowPacket {
bool is_valid();
private:
ByteBuffer payload_buffer_(MAX_ESPNOW_DATA_SIZE);
std::unique<ByteBuffer> payload_buffer_{nullptr};
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();
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();
}