On occasion (repeatable - if you disconnect the battery but have USB connected) the modem will stop responding to AT commands, it is therefore useless, and the entire point of being connected is compromised…
All attempts to restart the modem, and reconfigure it with Cellular.off() / Cellular.command() etc will fail, as there is no response to the AT prompt, and these functions work by relying on an AT response.
The only way to recover is to reset the entire unit which in turn issues a hardware reset to the modem.
While the modem comes up and reconnects, some of the existing sockets leave artifacts.
The function below needs to be called again, but it has a flag on it to get only called on boot.
int MDMParser::socketSocket(IpProtocol ipproto, int port)
if (!checkedOnce) {
checkedOnce = true; // prevent re-entry
DEBUG_D("On first socketSocket use, free all open sockets\r\n");
// Clean up any open sockets, we may have power cycled the STM32
// while the modem remained connected.
for (int s = 0; s < NUMSOCKETS; s++) {
_socketCloseHandleIfOpen(s);
// re-initialize the socket element
_socketFree(s);
}
}