summaryrefslogtreecommitdiff
path: root/fw/esp32/components/eos/cell_modem.c
diff options
context:
space:
mode:
Diffstat (limited to 'fw/esp32/components/eos/cell_modem.c')
-rw-r--r--fw/esp32/components/eos/cell_modem.c22
1 files changed, 20 insertions, 2 deletions
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;