From 92458eb1934e0f104f4a397c2c09ab2d19693436 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Fri, 23 Sep 2022 20:09:50 +0200 Subject: sleep respects modem_present flag --- fw/esp32/components/eos/cell_modem.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'fw/esp32/components/eos/cell_modem.c') diff --git a/fw/esp32/components/eos/cell_modem.c b/fw/esp32/components/eos/cell_modem.c index 029abe1..ec81111 100644 --- a/fw/esp32/components/eos/cell_modem.c +++ b/fw/esp32/components/eos/cell_modem.c @@ -58,6 +58,7 @@ static char uart_buf[EOS_CELL_UART_SIZE_BUF]; static size_t uart_buf_len; static char uart_buf_dirty = 0; +static uint8_t RTC_NOINIT_ATTR modem_present; static uint8_t RTC_NOINIT_ATTR modem_initialized; static uint8_t RTC_NOINIT_ATTR uart_mode; static uint8_t uart_mode_next = EOS_CELL_UART_MODE_NONE; @@ -176,7 +177,9 @@ static void uart_event_task(void *pvParameters) { r = at_expect("^OK", NULL, 500); if (!r) { r = eos_modem_atinit(); - if (r) { + if (!r) { + modem_present = 1; + } else { _mode = EOS_CELL_UART_MODE_NONE; ESP_LOGE(TAG, "Modem init failed"); } @@ -337,7 +340,11 @@ static void modem_event_task(void *pvParameters) { int r; r = modem_atinit(); - if (r) ESP_LOGE(TAG, "Modem init failed"); + if (!r) { + modem_present = 1; + } else { + ESP_LOGE(TAG, "Modem init failed"); + } break; } @@ -642,6 +649,7 @@ void eos_modem_init(void) { if (eos_power_wakeup_cause() == EOS_PWR_WAKE_RST) { uart_mode = EOS_CELL_UART_MODE_ATCMD; + modem_present = 0; modem_initialized = 0; modem_init_gpio(); } @@ -773,6 +781,16 @@ int eos_modem_readln(char *buf, size_t buf_size, uint32_t timeout) { return EOS_OK; } +int eos_modem_present(void) { + int rv; + + xSemaphoreTake(mutex, portMAX_DELAY); + rv = modem_present; + xSemaphoreGive(mutex); + + return rv; +} + uint8_t eos_modem_get_mode(void) { uint8_t ret; -- cgit v1.2.3