From 06d494ec4938ef8fe647cf77a033c06904bec3c7 Mon Sep 17 00:00:00 2001 From: NP v/d Spek Date: Tue, 8 Oct 2024 12:04:38 +0200 Subject: [PATCH] remove the link to bytebuffer. --- esphome/components/espnow/espnow.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/esphome/components/espnow/espnow.h b/esphome/components/espnow/espnow.h index de0ece2b46..66375bf576 100644 --- a/esphome/components/espnow/espnow.h +++ b/esphome/components/espnow/espnow.h @@ -5,7 +5,6 @@ #include "esphome/core/automation.h" #include "esphome/core/component.h" #include "esphome/core/helpers.h" -#include "esphome/core/bytebuffer.h" #include "esphome/core/log.h" #include @@ -254,7 +253,7 @@ template class SendAction : public Action, public Parente template void set_mac(V mac) { this->mac_ = mac; } template void set_command(V command) { this->command_ = command; } - void set_data_template(std::function func) { + void set_data_template(std::function(Ts...)> func) { this->data_func_ = func; this->static_ = false; } @@ -270,13 +269,10 @@ template class SendAction : public Action, public Parente command = this->mac_.value(x...); } - if (this->static_) { - this->parent_->get_default_protocol()->send(mac, this->data_static_.data(), this->data_static_.size(), command); - } else { - ByteBuffer data = this->data_func_(x...); - this->parent_->get_default_protocol()->send(mac, data.get_data().data(), (uint8_t) data.get_used_space(), - command); + if (!this->static_) { + this->data_static_ = this->data_func_(x...); } + this->parent_->get_default_protocol()->send(mac, this->data_static_.data(), this->data_static_.size(), command); } protected: