MQTT connection that works with shadow disconnected when calling OTA_AgentInit

My HW target is STM32L475
I have a basic application working with OTA and Shadow based on 201906.
I ported my application to 202002, I successfully activate the shadow part of my application.
I then tried to add the OTA supprt, mainly by calling OTA_AgentInit.
In my 201906 the OTA and the shadow shared the same MQTT connection and worked basically fine.
Now, on the updated environment (202002) I see that after calling OTA_AgentInit the next MQTT keep alive message does not get a PINGRESP and the MQTT is disconnected.
I thought it might be a memory issue but I checked my memory consumption and there is no problem with that.
What could be the problem?


Can you please share console logs so that we understand the sequence of operations? It seems that the Ping response timeout is not long enough and device might be disconnecting. You can also set MQTT logs to debug level before collecting the logs.

I’m not sure how, but the issue resolved.
I took the original 202002 (And not my application), started with the Shadow demo and then add a call to the OTA agent (see below), it worked and I did the same on my App with the same success so we can close this issue, thank you!

 if( status == EXIT_SUCCESS )
    /* Set the Shadow callbacks for this demo. */
    status = _setShadowCallbacks( &deltaSemaphore,
                                  thingNameLength );

OTA_ConnectionContext_t xOTAConnectionCtx = { 0 };

xOTAConnectionCtx.pvControlClient = mqttConnection;
xOTAConnectionCtx.pxNetworkInterface = ( void * ) pNetworkInterface;
xOTAConnectionCtx.pvNetworkCredentials = pNetworkCredentialInfo;

OTA_AgentInit( ( void * ) ( &xOTAConnectionCtx ), ( const uint8_t * ) ( clientcredentialIOT_THING_NAME ), App_OTACompleteCallback, ( TickType_t ) ~0 );

1 Like