I have ported the OTA windows demo to my platform. I’ve also integrated the FreeRTOS cellular interface in combination with a uBlox SARA-R4 modem.
I’ve been able to perform OTA cellular updates, now I would like to understand how this setup handles intermittent cellular connectivity.
I’m working on a hardware setup that should allow me to attenuate the cellular signal at the push of a button in such a way that the modem loses connectivity in order to simulate different test cases. This is proving harder that expected, ecspecially since a cell tower is located very close to my development workroom. Even with the antenna removed, there still is reception.
Can anyone tell me what the expected behavior is for the OTA demo in combination with the cellular interface when the connection is intermittent?
Do I need to implement something that listens for connection dropped/established call backs from the cellular layer and then call prvSuspendOTA/prvResumeOTA, or is this handled automatically through the existing interface through the functions:
TLS_FreeRTOS_Connect
TLS_FreeRTOS_Disconnect
TLS_FreeRTOS_recv
TLS_FreeRTOS_send
The OTA Library APIs to be used here are OTA_Suspend and OTA_Resume and prvSuspendOTA/prvResumeOTA are the demo examples. You can refer to the demos and will require to monitor disconnect callback to suspend OTA operations and when connection is established resume from where it was interrupted.
Is there some example code that can help me out for setting this up? I’m not sure which cellular callback would be best suited to trigger an OTA_Suspend/OTA_Resume.
Next to that, I’m unsure how the state machine in the cellular interface has been implemented. For example, will it after a connection loss automatically start a network search and re-connect when the network comes into range again?
Another unknown is whether or not I should also suspend/resume the MQTT agent.
If find that handling intermittent connectivity in a robust way is not well documented, yet it is essential to any product which makes use of a cellular connection, so I’m hoping examples exist so that I do not need to come up with my own implementation.
There are many reasons may cause cellular socket operation error. Intermittent connectivity is one reason and in extreme case cellular module may not response to AT command. I use this thread to discuss how to handle common error.
Cellular module not responding
This can be checked with simple “AT” command to see if “OK” is returned. If cellular modem can’t respond to AT command, reset cellular module is required. Before cellular module reset, Celllular_ClearUp() is required. After reset, setupCellular() provides example API calls to setup cellular modem.
Cellular network not registered
This cellular demo uses automatic mode (AT+COPS=0) to select network operator. If the cellular module loss network connection, it will search the network and try to re-connect. Cellular_GetServiceStatus can be used to query registration status. Use Cellular_RegisterUrcNetworkRegistrationEventCallback for callback function if required by application. There are many factors related to network searching speed, for example RAT and band selection. You can refer the SARA-R4 application note for network registration. RF off/on you mentioned in this thread is a way to reconnect network. It is suggested to do this with exponential back-off.
If you are using FreeRTOS OTA over MQTT demo, OTA_Suspend and OTA_Resume are handled in prvMQTTAgentTask. Cellular module status can be checked at this line.
The following graph is a brief flow chart about how to handle cellular error in OTA.