11static const char *
const TAG =
"espnow.transport";
19 ESP_LOGE(TAG,
"ESPNow component not set");
24 ESP_LOGI(TAG,
"Registering ESP-NOW handlers");
42 ESP_LOGE(TAG,
"ESPNow component not set");
47 ESP_LOGW(TAG,
"Attempted to send empty packet");
51 if (buf.size() > ESP_NOW_MAX_DATA_LEN) {
52 ESP_LOGE(TAG,
"Packet too large: %zu bytes (max %d)", buf.size(), ESP_NOW_MAX_DATA_LEN);
59 ESP_LOGW(TAG,
"Send failed: %d", err);
64bool ESPNowTransport::on_received(
const ESPNowRecvInfo &info,
const uint8_t *data, uint8_t size) {
65 ESP_LOGV(TAG,
"Received packet of size %u from %02X:%02X:%02X:%02X:%02X:%02X", size, info.
src_addr[0],
68 if (data ==
nullptr || size == 0) {
69 ESP_LOGW(TAG,
"Received empty or null packet");
73 this->packet_buffer_.resize(size);
74 memcpy(this->packet_buffer_.data(), data, size);
75 this->process_(this->packet_buffer_);
79bool ESPNowTransport::on_broadcasted(
const ESPNowRecvInfo &info,
const uint8_t *data, uint8_t size) {
80 ESP_LOGV(TAG,
"Received broadcast packet of size %u from %02X:%02X:%02X:%02X:%02X:%02X", size, info.
src_addr[0],
83 if (data ==
nullptr || size == 0) {
84 ESP_LOGW(TAG,
"Received empty or null broadcast packet");
88 this->packet_buffer_.resize(size);
89 memcpy(this->packet_buffer_.data(), data, size);
90 this->process_(this->packet_buffer_);
virtual void mark_failed()
Mark this component as failed.
ESPNowComponent * parent_
Handler interface for receiving broadcasted ESPNow packets Components should inherit from this class ...
Handler interface for receiving ESPNow packets Components should inherit from this class to handle in...
void send_packet(const std::vector< uint8_t > &buf) const override
bool should_send() override
peer_address_t peer_address_
Providing packet encoding functions for exchanging data with a remote host.
uint8_t src_addr[ESP_NOW_ETH_ALEN]
Source address of ESPNOW packet.