9 static const char *
const TAG =
"opentherm";
31 data.
valueHB = ch_enabled | (dhw_enabled << 1) | (cooling_enabled << 2) | (otc_enabled << 3) | (ch2_enabled << 4);
35 #pragma GCC diagnostic push 36 #pragma GCC diagnostic ignored "-Wswitch" 41 #pragma GCC diagnostic pop 51 ESP_LOGD(TAG,
"Received OpenTherm response with id %d (%s)", data.
id,
52 this->opentherm_->message_id_to_str((
MessageId) data.
id));
53 ESP_LOGD(TAG,
"%s", this->
opentherm_->debug_data(data).c_str());
57 ESP_LOGD(TAG,
"Setting up OpenTherm component");
60 ESP_LOGE(TAG,
"Failed to initialize OpenTherm protocol. See previous log messages for details.");
82 auto const cur_mode = this->
opentherm_->get_mode();
123 ESP_LOGE(TAG,
"OpenTherm is not idle at the start of the loop");
138 ESP_LOGE(TAG,
"Hub timeout triggered during send");
148 ESP_LOGW(TAG,
"Unexpected state after sending request: %s",
149 this->
opentherm_->operation_mode_to_str(this->opentherm_->get_mode()));
157 ESP_LOGE(TAG,
"Hub timeout triggered during receive");
166 }
else if (this->
opentherm_->is_protocol_error()) {
170 }
else if (!this->
opentherm_->has_message()) {
171 ESP_LOGW(TAG,
"Unexpected state after receiving response: %s",
172 this->
opentherm_->operation_mode_to_str(this->opentherm_->get_mode()));
183 "%d ms elapsed since the start of the last convo, but 1150 ms are allowed at maximum. Look at other " 184 "components that might slow the loop down.",
195 ESP_LOGV(TAG,
"Less than 100 ms elapsed since last convo, skipping this iteration");
212 ESP_LOGD(TAG,
"Sending request with id %d (%s)", request.id,
213 this->opentherm_->message_id_to_str((
MessageId) request.id));
214 ESP_LOGD(TAG,
"%s", this->
opentherm_->debug_data(request).c_str());
222 if (!this->
opentherm_->get_message(response)) {
223 ESP_LOGW(TAG,
"Couldn't get the response, but flags indicated success. This is a bug.");
241 ESP_LOGW(TAG,
"Error while sending request: %s",
242 this->
opentherm_->operation_mode_to_str(this->opentherm_->get_mode()));
243 ESP_LOGW(TAG,
"%s", this->
opentherm_->debug_data(this->last_request_).c_str());
249 ESP_LOGW(TAG,
"Protocol error occured while receiving response: %s", this->
opentherm_->debug_error(error).c_str());
253 ESP_LOGW(TAG,
"Receive response timed out at a protocol level");
259 #define SHOW(x) SHOW2(x) 262 ESP_LOGCONFIG(TAG,
"OpenTherm:");
263 LOG_PIN(
" In: ", this->
in_pin_);
265 ESP_LOGCONFIG(TAG,
" Sync mode: %d", this->
sync_mode_);
266 ESP_LOGCONFIG(TAG,
" Initial requests:");
268 ESP_LOGCONFIG(TAG,
" - %d",
type);
270 ESP_LOGCONFIG(TAG,
" Repeating requests:");
272 ESP_LOGCONFIG(TAG,
" - %d",
type);
bool should_skip_loop_(uint32_t cur_time) const
bool check_timings_(uint32_t cur_time)
void handle_protocol_read_error_()
uint32_t last_conversation_start_
std::unordered_set< MessageId > initial_messages_
void process_response(OpenthermData &data)
std::unordered_set< MessageId > repeating_messages_
timeout while waiting to receive bytes
InternalGPIOPin * in_pin_
std::unique_ptr< OpenTherm > opentherm_
void handle_protocol_write_error_()
uint32_t IRAM_ATTR HOT millis()
OpenthermData build_request_(MessageId request_id)
bool spin_wait_(uint32_t timeout, F func)
void start_conversation_()
uint32_t last_conversation_end_
InternalGPIOPin * out_pin_
std::unordered_set< MessageId >::const_iterator current_message_iterator_
void dump_config() override
virtual void mark_failed()
Mark this component as failed.
Implementation of SPI Controller mode.
void add_repeating_message(MessageId message_id)
Structure to hold Opentherm data packet content.
void handle_timeout_error_()
void on_shutdown() override