AWS OTA lib V2 example: missing subscription?

Hi,

I’d a small question about the new AWS OTA library. Specifically, in the OTA-Agent Orchestrator, I can’t see any MQTT subscription calls. In the simple OTA Orchestrator, a MQTT subscription is done just after the call to mqttDownloader_init. I assume there should still be calls to subscribe to the jobs and stream topics…

Am I missing something there ?

So you are missing something - but it’s not exactly obvious from the old OTA agent setup. I’ll try my best to provide code links with my explanation.

The old OTA Agent actually receives events (or messages) off of a Queue when used with FreeRTOS. The call stack is as follows…

Now that’s a bit of a ridiculous call stack just to get a single OTA message which is why we introduced the Orchestrator in our V2 OTA library. Now the example you’re looking at (OTA Agent Orchestrator) was written to very closely duplicate the behavior of our older OTA Agent library. Which is why the processOTAEvents function calls OtaReceiveEvent_FreeRTOS to read from the similarly supplied event queue.


Now with all of this said, you’ll need to register a callback with your MQTT/HTTP/Whatever messaging interface you use to place messages appropriately onto the event queue.

For your MQTT/HTTP/Messaging-interface callback, you can reference how this is setup in the OTA Agent Orchestrator by following the calls from mqttEventCallback through to otaDemo_handleIncomingMQTTMessage

I hope this helps!

Thank’s ok. I looked a bit deeper and, if I may resume, actually what I need to do in addition to the OTA orchestrator is to

  1. On startup, add a subscription to JOBS_API_SUBSCRIBE_NEXTJOBCHANGED(thing_name), and JOBS_API_SUBSCRIBE_JOBSCHANGED(thing_name).
  2. Moreover, when I call mqttDownloader_init, to init the file downloader library, I subscribe to the downloader topics, aka mqttFileDownloaderContext.topicStreamData.

The callbacks for the received messages seem reasonable (send event). My question was mainly for the subscription. I guess if I subscribe to the aforementioned topics and handle the callbacks correctly it should work right ?

Yep! That should work.

1 Like