ESPHome 2026.8.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>,
16 public ESPNowReceivedPacketHandler,
17 public ESPNowBroadcastHandler {
18 public:
19 void setup() override;
20 float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
21
22 void set_peer_address(peer_address_t address) {
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, uint16_t size) override;
28 bool on_broadcast(const ESPNowRecvInfo &info, const uint8_t *data, uint16_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 ESPNOW_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:1907
float get_setup_priority() const override
bool on_receive(const ESPNowRecvInfo &info, const uint8_t *data, uint16_t size) override
void send_packet(const std::vector< uint8_t > &buf) const override
std::vector< uint8_t > packet_buffer_
bool on_broadcast(const ESPNowRecvInfo &info, const uint8_t *data, uint16_t size) override
void set_peer_address(peer_address_t address)
constexpr float AFTER_WIFI
For components that should be initialized after WiFi is connected.
Definition component.h:55
uint16_t size
Definition helpers.cpp:25