other fix

This commit is contained in:
NP v/d Spek 2024-08-24 21:37:37 +02:00
parent 2d58a1ed02
commit d193d44e13
2 changed files with 8 additions and 11 deletions
esphome/components/espnow

View file

@ -5,11 +5,8 @@
static const char *const TAG = "espnow_packet"; static const char *const TAG = "espnow_packet";
ESPNowPacket::ESPNowPacket(const uint64_t mac64, const uint8_t *data, uint8_t size, ESPNowPacket::ESPNowPacket(const uint64_t mac64, const uint8_t *data, uint8_t size, uint32_t app_id)
uint32_t app_id) ESPHOME_ALWAYS_INLINE : mac64(mac64), : mac64(mac64), size(size), app_id(app_id), retrys(0) {
size(size),
app_id(app_id),
retrys(0) {
if (this->mac64 == 0) if (this->mac64 == 0)
this->mac64 = ESPNOW_BROADCAST_ADDR; this->mac64 = ESPNOW_BROADCAST_ADDR;
this->is_broadcast = this->mac64 == ESPNOW_BROADCAST_ADDR; this->is_broadcast = this->mac64 == ESPNOW_BROADCAST_ADDR;

View file

@ -60,8 +60,8 @@ struct ESPNowPacket {
} __attribute__((packed)); } __attribute__((packed));
}; };
inline ESPNowPacket() ESPHOME_ALWAYS_INLINE : retrys(0) {} ESPNowPacket() ESPHOME_ALWAYS_INLINE : retrys(0) {}
inline ESPNowPacket(const uint64_t mac64, const uint8_t *data, uint8_t size, uint32_t app_id); ESPNowPacket(const uint64_t mac64, const uint8_t *data, uint8_t size, uint32_t app_id);
inline void info(std::string place); inline void info(std::string place);
@ -87,11 +87,11 @@ struct ESPNowPacket {
bool is_valid(); bool is_valid();
inline std::string to_str(uint64_t mac64_ = 0) { inline std::string to_str(uint64_t mac64 = 0) {
espnow_addr_t mac; espnow_addr_t mac;
if (mac64_ == 0) if (mac64 == 0)
mac64_ = this->mac64; mac64 = this->mac64;
memcpy((void *) &mac, &mac64_, 6); memcpy((void *) &mac, &mac64, 6);
return string_format("{\"%02x:%02x:%02x:%02x:%02x:%02x\"}", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); return string_format("{\"%02x:%02x:%02x:%02x:%02x:%02x\"}", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
} }