lint and status check

This commit is contained in:
oarcher 2024-05-13 22:31:43 +02:00
parent 73ff266096
commit a3ed854b51
2 changed files with 28 additions and 29 deletions

View file

@ -74,16 +74,15 @@ void GSMComponent::setup() {
this->config_gpio_();
ESP_LOGI(TAG, "Status: %d", (int) this->get_status());
// to be sure the modem is not allready connected
this->powerdown();
if (this->get_status()) {
// at setup, the modem must be down
this->powerdown();
}
ESP_LOGV(TAG, "DTE setup");
esp_modem_dte_config_t dte_config = ESP_MODEM_DTE_DEFAULT_CONFIG();
this->dte_config_ = dte_config;
// this->dte_config_ = ESP_MODEM_DTE_DEFAULT_CONFIG();
this->dte_config_.uart_config.tx_io_num = this->tx_pin_;
this->dte_config_.uart_config.rx_io_num = this->rx_pin_;
// this->dte_config_.uart_config.rts_io_num = static_cast<gpio_num_t>( CONFIG_EXAMPLE_MODEM_UART_RTS_PIN);
@ -158,13 +157,11 @@ void GSMComponent::setup() {
void GSMComponent::start_connect_() {
this->connect_begin_ = millis();
this->status_set_warning();
this->status_set_warning("Starting connection");
ESP_LOGI(TAG, "Status: %d", (int) this->get_status());
this->poweron();
ESP_LOGI(TAG, "Status: %d", (int) this->get_status());
if (!this->get_status()) {
this->poweron();
}
// esp_err_t err;
// err = esp_netif_set_hostname(this->ppp_netif_, App.get_name().c_str());
@ -179,20 +176,22 @@ void GSMComponent::start_connect_() {
command_result res = command_result::TIMEOUT;
int retry = 0;
while (res != command_result::OK) {
res = this->dce_->sync();
if (res != command_result::OK) {
ESP_LOGW(TAG, "modem not responding");
ESP_LOGI(TAG, "Status: %d", (int) this->get_status());
this->dce_->set_command_mode();
App.feed_wdt();
vTaskDelay(pdMS_TO_TICKS(7000));
}
retry++;
if (retry > 10)
break;
}
// int retry = 0;
// while (res != command_result::OK) {
// res = this->dce_->sync();
// if (res != command_result::OK) {
// ESP_LOGW(TAG, "modem not responding");
// ESP_LOGI(TAG, "Status: %d", (int) this->get_status());
// this->dce_->set_command_mode();
// App.feed_wdt();
// vTaskDelay(pdMS_TO_TICKS(7000));
// }
// retry++;
// if (retry > 10)
// break;
// }
res = this->dce_->sync();
if (res != command_result::OK) {
ESP_LOGW(TAG, "Unable to sync modem. Will retry later");

View file

@ -47,10 +47,10 @@ class GSMComponent : public Component {
void set_tx_pin(gpio_num_t tx_pin) { this->tx_pin_ = tx_pin; }
void set_power_pin(gpio_num_t power_pin) { this->power_pin_ = power_pin; }
void set_flight_pin(gpio_num_t flight_pin) { this->flight_pin_ = flight_pin; }
void set_username(std::string username) { this->username_ = std::move(username); }
void set_password(std::string password) { this->password_ = std::move(password); }
void set_pin_code(std::string pin_code) { this->pin_code_ = std::move(pin_code); }
void set_apn(std::string apn) { this->apn_ = std::move(apn); }
void set_username(const std::string username) { this->username_ = std::move(username); }
void set_password(const std::string password) { this->password_ = std::move(password); }
void set_pin_code(const std::string pin_code) { this->pin_code_ = std::move(pin_code); }
void set_apn(const std::string apn) { this->apn_ = std::move(apn); }
void set_status_pin(gpio_num_t status_pin) { this->status_pin_ = status_pin; }
void set_dtr_pin(gpio_num_t dtr_pin) { this->dtr_pin_ = dtr_pin; }
void set_model(const std::string &model) {