Hi,
I am able to achieve AWS freertos MQTT demo running on my platform.
Also, I m able to sepratly run OTA demo in AWS freertos code. It is currently only running OTA agent.
If I updated the MQTT demo using AWS freertos OTA job, it will run MQTT “hello world” demo and disable OTA agent and will not be able to perform the next OTA cycle.
Now my query is how to merge them both in a single application that should not disable either or functionality?
Thank for update i will try and update.
meanwhile I want to understand, what is the use of OTA_UPDATE_DEMO in AWS freeRTOS, updating the OTA_UPDATE_DEMO demo itself, not updating the custom code?
What is the correct way to update my application using OTA_UPDATE_DEMO ?
Do you mean to ask the purpose of OTA demo? If so, it is meant to show how to use the OTA library to remotely update your firmware. Depending on your needs, you can use it as it is or modify it as per your requirements.
So, Lets. If I want to upgrade the AWS any of the demo (i.e. MQTT, SHADOW, ,TCP_ECHO_CLIENT, DEFENDER, GREENGRASS_DISCOVERY) using OTA_UPDATE_DEMO from AWS. How can I upgrade it?
I see - so what you are asking is how can you combine 2 demos. Like you want to run both MQTT and OTA. If that is correct, you will need to make some changes:
Those links are no longer available with the latest version of the demos.
I would love to have the same MQTT and OTA. I got OTA working with the latest demo, but I don’t know how to get a generic MQTT handler parsing JSON commands from a topic (turn this relay on/off).
What would be the best way to get that working?
Is there any sample project with OTA and MQTT handling?
The demo for OTA over MQTT makes use of both MQTT and OTA. The MQTT agent, created as a task here, can be used for both OTA and MQTT messages. You can then call MQTT-Agent functions to do things like message publication.
As mentioned by @aggarg above, it would be best to run the OTA and MQTT agents as separate tasks. Your JSON send & receive functionality can also be grouped into a separate task.
In the demo, the OTA agent and MQTT agent are already both individual tasks. This allows the MQTT manager to handle synchronization of what’s being sent and by whom. For example the MQTT agent might be sending a JSON message (like the one you’d like to handle) while the OTA Agent has requested to send a message which is turn queued to only send after the JSON message is sent successfully. Synchronization - one of the features of the MQTT agent - is important because it prevents two send or receive requests from clashing and causing problems.
In your case - running separate tasks will keep both your OTA, MQTT, and JSON messaging functionality cleaner, easier to maintain, and able to better utilize processor time.
For more on tasks, I’d highly recommend reading our getting started guide on the subject. Tasks and how they are scheduled are one of the most key concepts of what makes an RTOS what it is.