ESPHome 2026.5.1
Loading...
Searching...
No Matches
espnow_transport.h
Go to the documentation of this file.
1#pragma once
2
4
5#ifdef USE_ESP32
6
9
10#include <vector>
11
12namespace esphome::espnow {
13
15 public Parented<ESPNowComponent>,
18 public:
19 void setup() override;
20 float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
21
23 memcpy(this->peer_address_.data(), address.data(), ESP_NOW_ETH_ALEN);
24 }
25
26 // ESPNow handler interface
27 bool on_receive(const ESPNowRecvInfo &info, const uint8_t *data, uint8_t size) override;
28 bool on_broadcast(const ESPNowRecvInfo &info, const uint8_t *data, uint8_t size) override;
29
30 protected:
31 void send_packet(const std::vector<uint8_t> &buf) const override;
32 size_t get_max_packet_size() override { return ESP_NOW_MAX_DATA_LEN; }
33 bool should_send() override;
34
35 peer_address_t peer_address_{{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
36 std::vector<uint8_t> packet_buffer_;
37};
38
39} // namespace esphome::espnow
40
41#endif // USE_ESP32
uint8_t address
Definition bl0906.h:4
Helper class to easily give an object a parent of type T.
Definition helpers.h:1861
Handler interface for receiving ESPNow broadcast packets Components should inherit from this class to...
Handler interface for receiving ESPNow packets Components should inherit from this class to handle in...
float get_setup_priority() const override
bool on_broadcast(const ESPNowRecvInfo &info, const uint8_t *data, uint8_t size) override
bool on_receive(const ESPNowRecvInfo &info, const uint8_t *data, uint8_t size) override
void send_packet(const std::vector< uint8_t > &buf) const override
std::vector< uint8_t > packet_buffer_
void set_peer_address(peer_address_t address)
std::array< uint8_t, ESP_NOW_ETH_ALEN > peer_address_t
constexpr float AFTER_WIFI
For components that should be initialized after WiFi is connected.
Definition component.h:53
uint16_t size
Definition helpers.cpp:25