14 TEMPLATABLE_VALUE(std::vector<uint8_t>, data);
19 if (this->
flags_.wait_for_sent) {
25 if (this->
flags_.wait_for_sent) {
27 if (this->flags_.continue_on_error) {
28 this->play_next_(x...);
43 if (!this->sent_.empty()) {
44 this->sent_.play(
x...);
45 }
else if (this->flags_.wait_for_sent) {
46 this->play_next_(
x...);
49 if (!this->error_.empty()) {
50 this->error_.play(
x...);
51 }
else if (this->flags_.wait_for_sent) {
52 if (this->flags_.continue_on_error) {
53 this->play_next_(
x...);
61 std::vector<uint8_t> data = this->data_.value(
x...);
62 esp_err_t err = this->parent_->send(
address.data(), data, send_callback);
65 }
else if (!this->flags_.wait_for_sent) {
66 this->play_next_(
x...);
95 this->parent_->add_peer(
address.data());
105 this->parent_->del_peer(
address.data());
112 void play(Ts...
x)
override {
113 if (this->parent_->is_wifi_enabled()) {
116 this->parent_->set_wifi_channel(this->channel_.value(
x...));
117 this->parent_->apply_wifi_channel();
125 memcpy(this->address_,
address.data(), ESP_NOW_ETH_ALEN);
131 bool match = !this->has_address_ || (memcmp(this->address_, info.
src_addr, ESP_NOW_ETH_ALEN) == 0);
135 this->trigger(info, data, size);
140 bool has_address_{
false};
141 const uint8_t *address_[ESP_NOW_ETH_ALEN];
147 this->trigger(info, data, size);
155 memcpy(this->address_,
address.data(), ESP_NOW_ETH_ALEN);
160 bool match = !this->has_address_ || (memcmp(this->address_, info.
src_addr, ESP_NOW_ETH_ALEN) == 0);
164 this->trigger(info, data, size);
169 bool has_address_{
false};
170 const uint8_t *address_[ESP_NOW_ETH_ALEN];
void add_action(Action< Ts... > *action)
void add_actions(const std::vector< Action< Ts... > * > &actions)
Helper class to easily give an object a parent of type T.
void play(Ts... x) override
void play(Ts... x) override
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...
Handler interface for receiving ESPNow packets from unknown peers Components should inherit from this...
bool on_broadcasted(const ESPNowRecvInfo &info, const uint8_t *data, uint8_t size) override
OnBroadcastedTrigger(std::array< uint8_t, ESP_NOW_ETH_ALEN > address)
bool on_received(const ESPNowRecvInfo &info, const uint8_t *data, uint8_t size) override
OnReceiveTrigger(std::array< uint8_t, ESP_NOW_ETH_ALEN > address)
bool on_unknown_peer(const ESPNowRecvInfo &info, const uint8_t *data, uint8_t size) override
ActionList< Ts... > sent_
void play(Ts... x) override
uint8_t continue_on_error
void play_complex(Ts... x) override
ActionList< Ts... > error_
void add_on_sent(const std::vector< Action< Ts... > * > &actions)
void set_wait_for_sent(bool wait_for_sent)
struct esphome::espnow::SendAction::@81 flags_
void add_on_error(const std::vector< Action< Ts... > * > &actions)
void set_continue_on_error(bool continue_on_error)
TEMPLATABLE_VALUE(uint8_t, channel) void play(Ts... x) override
std::array< uint8_t, ESP_NOW_ETH_ALEN > peer_address_t
void esp_now_send_status_t status
std::function< void(esp_err_t)> send_callback_t
uint8_t src_addr[ESP_NOW_ETH_ALEN]
Source address of ESPNOW packet.