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...);
71 void play(
const Ts &...
x)
override {
93 void play(
const Ts &...
x)
override {
95 this->parent_->add_peer(
address.data());
103 void play(
const Ts &...
x)
override {
105 this->parent_->del_peer(
address.data());
110 TEMPLATABLE_VALUE(uint8_t, channel)
113 void play(
const Ts &...
x)
override {
114 if (this->parent_->is_wifi_enabled()) {
117 this->parent_->set_wifi_channel(this->channel_.value(
x...));
118 this->parent_->apply_wifi_channel();
126 memcpy(this->address_,
address.data(), ESP_NOW_ETH_ALEN);
132 bool match = !this->has_address_ || (memcmp(this->address_, info.
src_addr, ESP_NOW_ETH_ALEN) == 0);
136 this->trigger(info, data,
size);
141 bool has_address_{
false};
142 uint8_t address_[ESP_NOW_ETH_ALEN]{};
148 this->trigger(info, data,
size);
156 memcpy(this->address_,
address.data(), ESP_NOW_ETH_ALEN);
161 bool match = !this->has_address_ || (memcmp(this->address_, info.
src_addr, ESP_NOW_ETH_ALEN) == 0);
165 this->trigger(info, data,
size);
170 bool has_address_{
false};
171 uint8_t address_[ESP_NOW_ETH_ALEN]{};
void add_action(Action< Ts... > *action)
void add_actions(const std::initializer_list< Action< Ts... > * > &actions)
Helper class to easily give an object a parent of type T.
void play(const Ts &...x) override
void play(const Ts &...x) override
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...
Handler interface for receiving ESPNow packets from unknown peers Components should inherit from this...
bool on_broadcast(const ESPNowRecvInfo &info, const uint8_t *data, uint8_t size) override
OnBroadcastTrigger(std::array< uint8_t, ESP_NOW_ETH_ALEN > address)
bool on_receive(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(const Ts &...x) override
uint8_t continue_on_error
void play_complex(const Ts &...x) override
void add_on_error(const std::initializer_list< Action< Ts... > * > &actions)
ActionList< Ts... > error_
void set_wait_for_sent(bool wait_for_sent)
void add_on_sent(const std::initializer_list< Action< Ts... > * > &actions)
struct esphome::espnow::SendAction::@84 flags_
void set_continue_on_error(bool continue_on_error)
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.