1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-30 22:53:59 +00:00

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

View File

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