mirror of
https://github.com/esphome/esphome.git
synced 2024-12-11 14:49:20 +01:00
remove EbusSender
This commit is contained in:
parent
42d62c3124
commit
8cd7a78786
@ -45,12 +45,6 @@ void EbusComponent::set_command_queue_size(uint8_t command_queue_size) {
|
|||||||
this->command_queue_size_ = command_queue_size;
|
this->command_queue_size_ = command_queue_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EbusComponent::add_sender(EbusSender *sender) {
|
|
||||||
if (this->primary_address_ == SYN) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this->senders_.push_back(sender);
|
|
||||||
}
|
|
||||||
void EbusComponent::add_receiver(EbusReceiver *receiver) { this->receivers_.push_back(receiver); }
|
void EbusComponent::add_receiver(EbusReceiver *receiver) { this->receivers_.push_back(receiver); }
|
||||||
|
|
||||||
void EbusComponent::setup_queues_() {
|
void EbusComponent::setup_queues_() {
|
||||||
@ -172,8 +166,8 @@ void EbusComponent::update() {
|
|||||||
if (this->primary_address_ == SYN) {
|
if (this->primary_address_ == SYN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (auto const &sender : this->senders_) {
|
for (auto const &item : this->items_) {
|
||||||
optional<SendCommand> command = sender->prepare_command();
|
optional<SendCommand> command = item->prepare_command();
|
||||||
if (command.has_value()) {
|
if (command.has_value()) {
|
||||||
xQueueSendToBack(this->command_queue_, &command.value(), portMAX_DELAY);
|
xQueueSendToBack(this->command_queue_, &command.value(), portMAX_DELAY);
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,7 @@ class EbusReceiver {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
class EbusSender {
|
class EbusItem : public EbusReceiver, public Component {
|
||||||
public:
|
|
||||||
virtual optional<SendCommand> prepare_command() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class EbusItem : public EbusReceiver, public EbusSender, public Component {
|
|
||||||
public:
|
public:
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
|
|
||||||
@ -45,7 +40,7 @@ class EbusItem : public EbusReceiver, public EbusSender, public Component {
|
|||||||
void set_payload(const std::vector<uint8_t> &payload) { this->payload_ = payload; }
|
void set_payload(const std::vector<uint8_t> &payload) { this->payload_ = payload; }
|
||||||
void set_response_read_position(uint8_t response_position) { this->response_position_ = response_position; }
|
void set_response_read_position(uint8_t response_position) { this->response_position_ = response_position; }
|
||||||
|
|
||||||
optional<SendCommand> prepare_command() override;
|
virtual optional<SendCommand> prepare_command();
|
||||||
|
|
||||||
// TODO: refactor these
|
// TODO: refactor these
|
||||||
uint32_t get_response_bytes(Telegram &telegram, uint8_t start, uint8_t length);
|
uint32_t get_response_bytes(Telegram &telegram, uint8_t start, uint8_t length);
|
||||||
@ -77,10 +72,9 @@ class EbusComponent : public PollingComponent {
|
|||||||
void set_history_queue_size(uint8_t /*history_queue_size*/);
|
void set_history_queue_size(uint8_t /*history_queue_size*/);
|
||||||
void set_command_queue_size(uint8_t /*command_queue_size*/);
|
void set_command_queue_size(uint8_t /*command_queue_size*/);
|
||||||
|
|
||||||
void add_sender(EbusSender * /*sender*/);
|
|
||||||
void add_receiver(EbusReceiver * /*receiver*/);
|
void add_receiver(EbusReceiver * /*receiver*/);
|
||||||
void add_item(EbusItem *item) {
|
void add_item(EbusItem *item) {
|
||||||
this->add_sender(item);
|
this->items_.push_back(item);
|
||||||
this->add_receiver(item);
|
this->add_receiver(item);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -101,7 +95,7 @@ class EbusComponent : public PollingComponent {
|
|||||||
QueueHandle_t command_queue_;
|
QueueHandle_t command_queue_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::list<EbusSender *> senders_;
|
std::list<EbusItem *> items_;
|
||||||
std::list<EbusReceiver *> receivers_;
|
std::list<EbusReceiver *> receivers_;
|
||||||
|
|
||||||
std::unique_ptr<Ebus> ebus_;
|
std::unique_ptr<Ebus> ebus_;
|
||||||
|
Loading…
Reference in New Issue
Block a user