The best way to handle intermittent cellular connectivity in OTA?


I noticed that the OTA windows simulator demo does not resume correctly after the network connection was dropped and resumed again during an OTA download (LAN cable unplug/re-plug).

For my own application, my connection relies on a cellular connection, which frequently drops when travelling around. I have written my own layer that interfaces the OTA transport layer to the low level modem AT interface. It uses a state machine that continuously tries to reconnect after the connection has dropped. My current socket implementation still needs to implement how to handle these connection drops. And I wonder how to best implement that.

For instance, can my own socket implementation in the transport interface simply return
pdFREERTOS_ERRNO_ENOTCONN -128 // Socket is not connected
and when the connection comes back up again return:
pdFREERTOS_ERRNO_NONE 0 // No errors
or do I need to take additional actions? like perhaps halting the OTA agent thread upon a drop and resuming upon a connection.

Another possible approach could be to simply kill the OTA agent thread if the connection drops and restart it when the connection comes back up again. Eventually there will be a intermitting period which is long enough for a successful download, but that seems like a rather ugly way of doing it.

Hello @BaxEDM ,

When a connection drops you can shut down the OTA Agent by calling OTA_Shutdown and start it when the connection is back. However if you want to resume the download form the point it was interrupted you can suspend the OTA Agent when the connection drops by calling OTA_Suspend. When connection is back again you can call OTA_Resume to resume the interrupted download if any when it was suspended.

Please let me know if that answers your question.