cancel
Showing results for 
Search instead for 
Did you mean: 

Software on Silicon Blog

Yeshwanth_KT
Employee

Implementing OTA client using AnyCloud libraries

AnyCloud is a collection of software libraries through which one can rapidly develop Wi-Fi and Bluetooth applications on PSoC 6 MCU and CYW43xxx Wi-Fi + Bluetooth combo devices. This is a very flexible solution and doesn’t tie you to a specific cloud management service. It is also seamlessly integrated into our ModusToolbox ecosystem which helps you to create system-level projects with ease.

In the latest release, AnyCloud provides great new features, such as the Wi-Fi Connection Manager, a Secure Socket layer, support for the MQTT protocol, HTTP client and server, Over-the-Air updates (OTA), Bluetooth Low Energy functionality, and Low Power Assist. In this blog, we will look at an overview of the OTA operation and see how to configure PSoC 6 MCU as an OTA client using the AnyCloud libraries.

Over-the-Air update

Over-the-Air update or popularly known as OTA update is a technology that is used to wirelessly deliver software, firmware, or any other data to a mobile device. A central server can send an update to all the users subscribed to a channel at once. This ensures that the devices operating on the field are always up to date with the latest features and security patches.

In general, the device receiving the update will have a bootloader application that takes care of scheduling, verifying, and patching the new firmware image.

Over-the-Air update features of AnyCloud

The anycloud-ota library supports OTA updates through Wi-Fi on a PSoC 6 MCU with CYW43xxx connectivity device. This library utilizes MQTT or HTTPS protocols to connect to an “MQTT broker” or ”HTTPS server” and download an update for the user application.

As mentioned earlier, a bootloader application is required to patch the new firmware image that is downloaded. The recommended bootloader is MCUBoot. It is an open-source library enabling the development of secure bootloader applications for 32-bit MCUs. Refer to mtb-example-psoc6-mcuboot-basic code example to learn more about its features and configuration for PSoC 6 MCU devices.

OTA using MQTT

 

mqtt.png

The OTA update over MQTT can be depicted by the above flowchart. There are three nodes in this flow: IoT device, MQTT Broker, and Publisher/Server.

The IoT device running a user application that wants the OTA updates runs the OTA agent. The OTA agent takes care of creating and maintaining the communication channel with the MQTT broker. The anycloud-ota library provides a single function to create and start this OTA agent. The operations on the IoT Device side are all done by the anycloud-ota library, the user application will receive the status of these operations through a registered callback.

The MQTT broker can be any server of your choice. It acts as the communication bridge between the IoT device and the Publisher.

The Publisher/Server is a node that publishes the new image to the MQTT broker on demand by the IoT device. This node stores the latest firmware images and respective job documents. Every time when the IoT device checks for an update, the publisher sends the latest job document. The job document has information such as image version, kit name, manufacturer details, etc. The IoT device will decide whether the update is required or not based on the content of this job document.

The mtb-example-anycloud-ota-mqtt code example demonstrates OTA over MQTT. The MQTT broker used in this example is a locally installable mosquito and the publisher is a custom python script. The README document of the code example has detailed information on how to set up and run the example. We would recommend running this example to understand the various components, tools, and assets involved in building a simple OTA over MQTT application.

OTA using HTTPs

http.png

The OTA update over HTTPS is quite simpler as it only involves two nodes: IoT device and server.

The operations on the IoT device side are similar to those explained in the OTA over the MQTT section. The only difference here is that the OTA agent connects to an HTTPS file server instead of an MQTT broker. The OTA agent creates and manages this HTTPS connection.

The IoT server is an HTTPS file server that hosts the latest firmware images and respective job documents. When the IoT device checks for an update, it sends an HTTPS GET request to fetch the job document. Based on the content of the job document, the IoT device decides whether to fetch the image or not.

The mtb-example-anycloud-ota-https code example demonstrates OTA over HTTPS. This example uses a local HTTPS file server created using a node.js based local-web-server. The README document of the code example has detailed information on how to set up and run the example. We would again recommend running this example as well to understand the various components, tools, and assets involved in building a simple OTA over an HTTPS application.

Make sure to check out other AnyCloud code examples from the Cypress GitHub repository.

0 Likes