AWS FreeRtos OTA

I am using the AWS OTA Demo , modified with a time out if no update is found at power up. This means it can exit and get on with other things such as shadow or MQTT , this is working as expected with no issues and updates OTA work just fine.

The problem occurs when I run AWS OTA Demo from within the main program loop , I end up with a memory leak every time the OTA demo is run and eventually it crashes (out of memory).
To get it to run the subscriptions again , I add the following

xOTA_Agent.eState = eOTA_AgentState_Stopped;
xOTA_Agent.eImageState = eOTA_ImageState_Unknown;

to make it do a restart, without this it does not subscribe to the OTA topic and the demo timeouts out without any memory leak.

I cannot see were the leak is occurring or how to resolve the problem

any ideas welcome

thanks

Hello,

Can you please share information on how you are using timeouts to stop the OTA Agent ? Are you shutting down the Agent and then reinitializing ?

Hi

Thanks for the response

Within vRunOTAUpdateDemo( pNetworkInterface, pNetworkCredentialInfo );

This routine has a for( ; ; ) loop in it which in the standard AWS code does not exit if no update is available

I have added a timeout variable which when zero runs a break; command to exist the for loop

Also after

vRunOTAUpdateDemo( pNetworkInterface, pNetworkCredentialInfo );

I added, although this appear to have little effect in reducing memory leak

if( xSubscriptionHandle != IOT_NETWORK_MANAGER_SUBSCRIPTION_INITIALIZER )

{

AwsIotNetworkManager_RemoveSubscription( xSubscriptionHandle );

}

if( xNetworkAvailableLock != NULL )

{

vSemaphoreDelete( xNetworkAvailableLock );

}

if( bMqttInitialized == true )

{

IotMqtt_Cleanup();

}

Regards

Simon

Hi Again

Not sure how to go about stopping OTA_agent please advise

Thanks

Hello,

The OTA Agent can be shutdown using the API described here https://freertos.org/Documentation/api-ref/ota/ota_function_shutdown.html which will perform the cleanup. You can then re initialize it based on your application requirement.