feat(modem): Add mode detection to the example

This commit is contained in:
David Cermak
2024-12-06 09:29:35 +01:00
parent 1db83cd1ca
commit 18f196fa1e
5 changed files with 62 additions and 3 deletions

View File

@@ -91,6 +91,11 @@ public:
return mode.set(dte.get(), device.get(), netif, m);
}
modem_mode get_mode()
{
return mode.get();
}
bool recover()
{
return dte->recover();
@@ -109,11 +114,12 @@ public:
* @param force true to ignore command failures and continue
* @return command_result of the underlying commands
*/
command_result pause_netif(bool do_pause, bool force = false)
command_result pause_netif(bool do_pause, bool force = false, int delay = 1000)
{
command_result result;
if (do_pause) {
netif.pause();
Task::Delay(delay); // Mandatory 1s pause before
dte->set_command_callbacks();
result = device->set_command_mode();
} else {

View File

@@ -45,6 +45,8 @@ typedef enum esp_modem_dce_mode {
ESP_MODEM_MODE_CMUX_MANUAL_SWAP, /**< Swap terminals in CMUX manual mode */
ESP_MODEM_MODE_CMUX_MANUAL_DATA, /**< Set DATA mode in CMUX manual mode */
ESP_MODEM_MODE_CMUX_MANUAL_COMMAND, /**< Set COMMAND mode in CMUX manual mode */
ESP_MODEM_MODE_DETECT, /**< Detect the mode and resume it (if sucessfully detected) */
ESP_MODEM_MODE_UNDEF,
} esp_modem_dce_mode_t;
/**
@@ -171,6 +173,7 @@ esp_err_t esp_modem_set_urc(esp_modem_dce_t *dce, esp_err_t(*got_line_cb)(uint8_
*/
esp_err_t esp_modem_pause_net(esp_modem_dce_t *dce, bool pause);
esp_modem_dce_mode_t esp_modem_get_mode(esp_modem_dce_t *dce);
/**
* @}
*/