From 0c55dbb7a486cea9afd8b047ca8914a3df1e11ab Mon Sep 17 00:00:00 2001 From: Chelios Date: Fri, 18 Oct 2024 23:10:09 +0300 Subject: [PATCH] execute dce_init before transition to state to sync --- esphome/components/modem/modem_component.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/esphome/components/modem/modem_component.cpp b/esphome/components/modem/modem_component.cpp index 65e7ba7d0f..3ac4e3bf65 100644 --- a/esphome/components/modem/modem_component.cpp +++ b/esphome/components/modem/modem_component.cpp @@ -112,7 +112,6 @@ void ModemComponent::loop() { this->set_state(ModemComponentState::TURNING_ON_POWER); break; } - this->dce_init(); break; // The state releases the power key @@ -133,7 +132,6 @@ void ModemComponent::loop() { this->set_state(ModemComponentState::TURNING_OFF_POWER); break; } - this->dce_init(); break; // The state of the end of the reset of the modem @@ -233,6 +231,16 @@ bool ModemComponent::check_modem_component_state_timings() { } void ModemComponent::set_state(ModemComponentState state) { + // execute before transition to state + switch (state) + { + case ModemComponentState::SYNC: + this->dce_init(); + break; + + default: + break; + } ESP_LOGCONFIG(TAG, "Modem component change state from %s to %s", this->state_to_string(this->state_), this->state_to_string(state)); this->state_ = state;