ESPHome 2025.11.0b4
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 {
13namespace espnow {
14
16 public Parented<ESPNowComponent>,
19 public:
20 void setup() override;
21 void update() override;
22 float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
23
25 memcpy(this->peer_address_.data(), address.data(), ESP_NOW_ETH_ALEN);
26 }
27
28 // ESPNow handler interface
29 bool on_received(const ESPNowRecvInfo &info, const uint8_t *data, uint8_t size) override;
30 bool on_broadcasted(const ESPNowRecvInfo &info, const uint8_t *data, uint8_t size) override;
31
32 protected:
33 void send_packet(const std::vector<uint8_t> &buf) const override;
34 size_t get_max_packet_size() override { return ESP_NOW_MAX_DATA_LEN; }
35 bool should_send() override;
36
37 peer_address_t peer_address_{{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
38 std::vector<uint8_t> packet_buffer_;
39};
40
41} // namespace espnow
42} // namespace esphome
43
44#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:901
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...
float get_setup_priority() const override
bool on_received(const ESPNowRecvInfo &info, const uint8_t *data, uint8_t size) override
bool on_broadcasted(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
const float AFTER_WIFI
For components that should be initialized after WiFi is connected.
Definition component.cpp:66
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7