From 171213fe38c7b2138cd86074e8e843862e64054f Mon Sep 17 00:00:00 2001 From: oarcher Date: Mon, 22 Jul 2024 01:09:43 +0200 Subject: [PATCH] disable on sim error --- esphome/components/modem/modem_component.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/esphome/components/modem/modem_component.cpp b/esphome/components/modem/modem_component.cpp index aa167aa4de..bd20f40c64 100644 --- a/esphome/components/modem/modem_component.cpp +++ b/esphome/components/modem/modem_component.cpp @@ -306,6 +306,8 @@ void ModemComponent::loop() { ESP_LOGI(TAG, "Starting modem connection"); this->state_ = ModemComponentState::CONNECTING; this->start_connect_(); + } else { + this->disable(); } } else { this->state_ = ModemComponentState::NOT_RESPONDING; @@ -404,6 +406,7 @@ void ModemComponent::loop() { } void ModemComponent::enable() { + ESP_LOGD(TAG, "Enabling modem"); if (this->state_ == ModemComponentState::DISABLED) { this->state_ = ModemComponentState::DISCONNECTED; } @@ -412,8 +415,13 @@ void ModemComponent::enable() { } void ModemComponent::disable() { + ESP_LOGD(TAG, "Disabling modem"); this->enabled_ = false; - this->state_ = ModemComponentState::DISCONNECTING; + if (this->state_ == ModemComponentState::CONNECTED) { + this->state_ = ModemComponentState::DISCONNECTING; + } else { + this->state_ = ModemComponentState::DISCONNECTED; + } } void ModemComponent::dump_connect_params_() {