Hi all
My current code looks like:
void mqttOnDisconnect()
{
disconnected = true;
}
...
IotMqtt_Connect(...)
IotMqtt_TimedSubscribe(...)
OTA_AgentInit(...)
while(!disconnected)
{
...
}
OTA_AgentShutdown(...)
I pull the ethernet plug and get mqttOnDisconnect(KEEP_ALIVE_TIMEOUT)
as expected.
Problem here is that by the time OTA_AgentShutdown()
is called the MQTT connection is aleady closed and _IotMqtt_RemoveSubscriptionByTopicFilter()
hangs on ASSERT (contextIndex = -1).
I then tried moving OTA_AgentShutdown()
to mqttOnDisconnect()
, but it looks as if OTA spins off a job that ends up calling _IotMqtt_RemoveSubscriptionByTopicFilter()
after OTA_AgentShutdown()
returns (leading to mqttOnDisconnect()
returning leading to MQTT closing the connection).
So, when do I call OTA_AgentShutdown()
or don’t I need to do that (i.e. does MQTT clean that up properly?)
Or do I need to wait for OTA to shutdown in mqttOnDisconnect? This feels… wrong somehow
Thanks
W