From ce44dd9b1ba138a8c40a4cdf063f6d8a2614ed92 Mon Sep 17 00:00:00 2001 From: Guido Schreuder Date: Sun, 25 Feb 2024 00:59:19 +0100 Subject: [PATCH] use vector in SendCommand --- esphome/components/ebus/ebus_component.cpp | 2 +- esphome/components/ebus/telegram.cpp | 8 ++++---- esphome/components/ebus/telegram.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/esphome/components/ebus/ebus_component.cpp b/esphome/components/ebus/ebus_component.cpp index 5b37481bab..d68c8e6f08 100644 --- a/esphome/components/ebus/ebus_component.cpp +++ b/esphome/components/ebus/ebus_component.cpp @@ -197,7 +197,7 @@ optional EbusSensorBase::prepare_command() { if (this->send_poll_) { command = SendCommand( // - this->parent_->get_primary_address(), this->address_, this->command_, this->payload_.size(), &this->payload_[0]); + this->parent_->get_primary_address(), this->address_, this->command_, this->payload_); } return command; } diff --git a/esphome/components/ebus/telegram.cpp b/esphome/components/ebus/telegram.cpp index e71c4fcb1c..2bcb77a46b 100644 --- a/esphome/components/ebus/telegram.cpp +++ b/esphome/components/ebus/telegram.cpp @@ -104,15 +104,15 @@ bool Telegram::is_request_valid() { SendCommand::SendCommand() { this->state_ = TelegramState::endCompleted; } -SendCommand::SendCommand(uint8_t qq, uint8_t zz, uint16_t command, uint8_t nn, uint8_t *data) { +SendCommand::SendCommand(uint8_t qq, uint8_t zz, uint16_t command, std::vector &data) { this->state_ = TelegramState::waitForSend; this->push_req_data(qq); this->push_req_data(zz); this->push_req_data(command >> 8); this->push_req_data(command & 0xFF); - this->push_req_data(nn); - for (int i = 0; i < nn; i++) { - this->push_req_data(data[i]); + this->push_req_data(data.size()); + for (int i = 0; i < data.size(); i++) { + this->push_req_data(data.at(i)); } this->push_req_data(this->request_rolling_crc_); } diff --git a/esphome/components/ebus/telegram.h b/esphome/components/ebus/telegram.h index 48afd9c5c5..5f1f245738 100644 --- a/esphome/components/ebus/telegram.h +++ b/esphome/components/ebus/telegram.h @@ -132,7 +132,7 @@ class Telegram : public TelegramBase { class SendCommand : public TelegramBase { public: SendCommand(); - SendCommand(uint8_t qq, uint8_t zz, uint16_t command, uint8_t nn, uint8_t *data); + SendCommand(uint8_t qq, uint8_t zz, uint16_t command, std::vector &data); bool can_retry(int8_t max_tries); uint8_t get_crc();