add timings

This commit is contained in:
Alexandr Pyslar 2024-10-09 17:47:24 +00:00
parent b833b263cc
commit ea4fc0908c
2 changed files with 21 additions and 12 deletions

View file

@ -17,6 +17,8 @@
uint32_t time_info_print = 0; uint32_t time_info_print = 0;
uint32_t time_hard_reset_modem = 0; uint32_t time_hard_reset_modem = 0;
uint32_t time_check_rssi = 0; uint32_t time_check_rssi = 0;
uint32_t time_push_pwrkey = 0;
uint32_t time_turn_on_modem = 0;
#define TIME_TO_NEXT_HARD_RESET 30000 #define TIME_TO_NEXT_HARD_RESET 30000
#define TIME_TO_START_MODEM 9000 #define TIME_TO_START_MODEM 9000
@ -60,7 +62,6 @@ void ModemComponent::setup() {
this->use_pwrkey(); this->use_pwrkey();
// esp_modem_hard_reset(); // esp_modem_hard_reset();
if (esp_reset_reason() != ESP_RST_DEEPSLEEP) { if (esp_reset_reason() != ESP_RST_DEEPSLEEP) {
// Delay here to allow power to stabilise before Modem is initialized. // Delay here to allow power to stabilise before Modem is initialized.
delay(300); // NOLINT delay(300); // NOLINT
@ -123,6 +124,13 @@ void ModemComponent::loop() {
} }
} }
break; break;
case ModemComponentState::RESETTING:
break;
case ModemComponentState::TURNING_ON:
break;
case ModemComponentState::TURNING_OFF:
break;
case ModemComponentState::CONNECTING: case ModemComponentState::CONNECTING:
break; break;
case ModemComponentState::CONNECTED: case ModemComponentState::CONNECTED:
@ -142,11 +150,11 @@ void ModemComponent::loop() {
bool ModemComponent::turn_on_modem() { bool ModemComponent::turn_on_modem() {
if (this->power_pin_) { if (this->power_pin_) {
this->power_pin_->digital_write(true); this->power_pin_->digital_write(true);
time_turn_on_modem = millis();
vTaskDelay(pdMS_TO_TICKS(1900)); // NOLINT vTaskDelay(pdMS_TO_TICKS(1900)); // NOLINT
ESP_LOGD(TAG, "modem is on"); ESP_LOGD(TAG, "modem is on");
return true; return true;
} } else {
else {
ESP_LOGD(TAG, "failed to turn on modem because power_pin_ is not initialized"); ESP_LOGD(TAG, "failed to turn on modem because power_pin_ is not initialized");
return false; return false;
} }
@ -159,8 +167,7 @@ bool ModemComponent::turn_off_modem(){
vTaskDelay(pdMS_TO_TICKS(1900)); // NOLINT vTaskDelay(pdMS_TO_TICKS(1900)); // NOLINT
ESP_LOGD(TAG, "modem is off"); ESP_LOGD(TAG, "modem is off");
return true; return true;
} } else {
else {
ESP_LOGD(TAG, "failed to turn off modem because power_pin_ is not initialized"); ESP_LOGD(TAG, "failed to turn off modem because power_pin_ is not initialized");
return false; return false;
} }
@ -173,8 +180,7 @@ bool ModemComponent::use_pwrkey(){
this->pwrkey_pin_->digital_write(false); this->pwrkey_pin_->digital_write(false);
vTaskDelay(pdMS_TO_TICKS(1050)); // NOLINT vTaskDelay(pdMS_TO_TICKS(1050)); // NOLINT
this->pwrkey_pin_->digital_write(true); this->pwrkey_pin_->digital_write(true);
} } else {
else {
ESP_LOGD(TAG, "failed to press button because pwrkey_pin_ is not initialized"); ESP_LOGD(TAG, "failed to press button because pwrkey_pin_ is not initialized");
} }
return true; return true;

View file

@ -26,6 +26,9 @@ enum ModemType {
enum class ModemComponentState { enum class ModemComponentState {
STOPPED, STOPPED,
RESETTING,
TURNING_ON,
TURNING_OFF,
CONNECTING, CONNECTING,
CONNECTED, CONNECTED,
}; };