Skip to content

Commit 1a9eaf3

Browse files
committed
fix(modem): Fix console example to use urc/detect features
1 parent 52598e5 commit 1a9eaf3

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

components/esp_modem/examples/modem_console/main/modem_console_main.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Unlicense OR CC0-1.0
55
*/
@@ -89,7 +89,7 @@ void wakeup_modem(void)
8989
vTaskDelay(pdMS_TO_TICKS(2000));
9090
}
9191

92-
#ifdef CONFIG_EXAMPLE_MODEM_DEVICE_SHINY
92+
#ifdef CONFIG_ESP_MODEM_URC_HANDLER
9393
command_result handle_urc(uint8_t *data, size_t len)
9494
{
9595
ESP_LOG_BUFFER_HEXDUMP("on_read", data, len, ESP_LOG_INFO);
@@ -238,7 +238,9 @@ extern "C" void app_main(void)
238238
if (c->get_count_of(&SetModeArgs::mode)) {
239239
auto mode = c->get_string_of(&SetModeArgs::mode);
240240
modem_mode dev_mode;
241-
if (mode == "UNDEF") {
241+
if (mode == "AUTO") {
242+
dev_mode = esp_modem::modem_mode::AUTODETECT;
243+
} else if (mode == "UNDEF") {
242244
dev_mode = esp_modem::modem_mode::UNDEF;
243245
} else if (mode == "CMUX1") {
244246
dev_mode = esp_modem::modem_mode::CMUX_MANUAL_MODE;
@@ -370,15 +372,15 @@ extern "C" void app_main(void)
370372
ESP_LOGI(TAG, "Resetting the module...");
371373
CHECK_ERR(dce->reset(), ESP_LOGI(TAG, "OK"));
372374
});
373-
#ifdef CONFIG_EXAMPLE_MODEM_DEVICE_SHINY
375+
#ifdef CONFIG_ESP_MODEM_URC_HANDLER
374376
const ConsoleCommand HandleURC("urc", "toggle urc handling", no_args, [&](ConsoleCommand * c) {
375377
static int cnt = 0;
376378
if (++cnt % 2) {
377379
ESP_LOGI(TAG, "Adding URC handler");
378-
dce->set_on_read(handle_urc);
380+
dce->set_urc(handle_urc);
379381
} else {
380382
ESP_LOGI(TAG, "URC removed");
381-
dce->set_on_read(nullptr);
383+
dce->set_urc(nullptr);
382384
}
383385
return 0;
384386
});

0 commit comments

Comments
 (0)