#pragma once #include "esphome/core/component.h" #include "esphome/core/automation.h" #include "esphome/components/sx127x/sx127x.h" namespace esphome { namespace sx127x { template class RunImageCalAction : public Action, public Parented { public: void play(Ts... x) override { this->parent_->run_image_cal(); } }; template class SendPacketAction : public Action, public Parented { public: void set_data_template(std::function(Ts...)> func) { this->data_func_ = func; this->static_ = false; } void set_data_static(const std::vector &data) { this->data_static_ = data; this->static_ = true; } void play(Ts... x) override { if (this->static_) { this->parent_->transmit_packet(this->data_static_); } else { this->parent_->transmit_packet(this->data_func_(x...)); } } protected: bool static_{false}; std::function(Ts...)> data_func_{}; std::vector data_static_{}; }; template class SetModeTxAction : public Action, public Parented { public: void play(Ts... x) override { this->parent_->set_mode_tx(); } }; template class SetModeRxAction : public Action, public Parented { public: void play(Ts... x) override { this->parent_->set_mode_rx(); } }; template class SetModeSleepAction : public Action, public Parented { public: void play(Ts... x) override { this->parent_->set_mode_sleep(); } }; template class SetModeStandbyAction : public Action, public Parented { public: void play(Ts... x) override { this->parent_->set_mode_standby(); } }; } // namespace sx127x } // namespace esphome