espressif / esp-protocols

Collection of ESP-IDF components related to networking protocols
198 stars 135 forks source link

Is there a way to send AT commands while keeping the connection, without using CMUX? (IDFGH-14106) #699

Open doragasu opened 5 days ago

doragasu commented 5 days ago

Answers checklist.

General issue report

I'm using a Quectel MC60 modem. In CMUX mode, I can get Internet connectivity and simultaneously send AT commands (I need to periodically get signal quality). The problem is that now I am optimizing power consumption, and the modem refuses to enter sleep mode if CMUX is active, so I am forced to use DATA mode.

While in DATA mode, sending commands to the modem does not work, and if I momentarily try switching to COMMAND mode, the connection is immediately dropped. When many years ago I made my own modem drivers, I was able to momentarily switch to command mode (using the "+++" escape sequence), send the AT command, and return to DATA mode without interrupting the connection. Is this possible in any way?

TL;DR: Is there a way to get the signal quality (or send any other AT command) when using DATA mode, without interrupting the connectivity?

david-cermak commented 5 days ago

esp_modem doesn't support it ATM, but I find it quite helpful (also used it to perform OTA in the past). I've put up a sketch PR: https://github.com/espressif/esp-protocols/pull/700, which allows you to pause a network connection and bring up the AT interface.

doragasu commented 5 days ago

Thanks!

With that patch, invoking pause(true) also switches to command mode, right? Or should I manually switch after the pause?

david-cermak commented 5 days ago

With that patch, invoking pause(true) also switches to command mode, right? Or should I manually switch after the pause?

It sends the corresponding AT commands, yes, but the mode stays the same.

To test it, you need to switch to the data mode first. Then:

doragasu commented 5 days ago

I see, thanks.

About the discarded network data, I suppose data from the ESP host to the modem is discarded (but I could maybe workaround that with a lock), and data from the modem to the ESP will be buffered by the modem until I unpause (so when using TCP, no data loss should occur).