diff --git a/esphome/components/modem/modem_component.cpp b/esphome/components/modem/modem_component.cpp index c7916516ac..291566557c 100644 --- a/esphome/components/modem/modem_component.cpp +++ b/esphome/components/modem/modem_component.cpp @@ -52,7 +52,7 @@ ModemComponent::ModemComponent() { } std::string ModemComponent::send_at(const std::string &cmd) { - std::string result; + std::string result = "ERROR"; command_result status = command_result::FAIL; ESP_LOGV(TAG, "Sending command: %s", cmd.c_str()); if (this->modem_ready()) { @@ -60,9 +60,6 @@ std::string ModemComponent::send_at(const std::string &cmd) { ESP_LOGV(TAG, "Result for command %s: %s (status %s)", cmd.c_str(), result.c_str(), command_result_to_string(status).c_str()); } - if (status != esp_modem::command_result::OK) { - result = "ERROR"; - } return result; } @@ -560,6 +557,9 @@ bool ModemComponent::modem_sync_() { if (status && !this->internal_state_.modem_synced) { // First time the modem is synced, or modem recovered this->internal_state_.modem_synced = true; + + ESPMODEM_ERROR_CHECK(this->dce->set_gnss_power_mode(this->gnss_), "Enabling/disabling GNSS"); + if (!this->prepare_sim_()) { // fatal error this->disable();