OTA + FreeRTOS Cellular is a power hog; How to use eDRX?

Hi,

I’m using the OTA library in combination with the FreeRTOS cellular interface. I’m running it just as provided in the examples. The continuous cellular connection and the OTA client pings are a real power drain in my battery powered application.
The modem I’m using, the uBlox SARA-R4, features the power saving eDRX function. Can anyone here elaborate on a high level how this should be used in combination with the OTA library? Are there any examples?

It is not necessary to keep the connection open the whole time for the OTA library - you can connect periodically to see if there are OTA updates.

Ok, so what would be a good approach? Periodically alternate between an active and a low power state, by calling the following to enter low power:

prvSuspendOTA();
prvSocketDisconnect();
powerdowncellular();

And then do this to enter the active state again:

powerupcellular();
prvConnectToMQTTBroker();
prvResumeOTA();

Would that be a good approach?

Your approach sounds like it should work.

However before calling prvSocketDisconnect() you should also disconnect the MQTT connection. You can call MQTTAgent_Disconnect as a thread safe API to disconnect ongoing MQTT connection. Once MQTT Agent comes out of the command loop you can then disconnect the underlying socket connection.