Adding devices in an IoT platform isn’t the end of the process. Often, you might need to update them for new features or security upgrades. Naturally, updating remote devices by calling them physically is not at all feasible. With firmware updates over-the-air (OTA), we can ensure that the IoT ecosystem stay always up-to-date.
OTA firmware updates are a vital component of any IoT system. OTA updates refer to the practice of remotely updating the code on a device.
We implemented a callback function on the IoTConnect device SDK to receive data from the cloud. It depends on the device connection that is called automatically. You will receive the OTA firmware information and device command from the cloud, and perform a pre-defined action.
How does firmware updates work in IoTConnect
Updating firmware is a relatively domain-independent operation that requires you to provide the version of the update and a file associated with it. The firmware version is associated with the template that you need to create at a later stage.
Hardware version is unique to the system as it cannot be deleted or modified once released. The software version is associated with each hardware version which can be updated when required.
Once you have released the firmware version, you cannot edit or delete it as it is already being used by the hardware associated with it.
How to create and send the OTA update
IoTConnect OTA covers in three sections.
1. Prepare Firmware
- Based on the device requirement, a firmware developer can develop and prepare a file(s).
- It is the device manufacturer’s responsibility to create firmware based on the requirement. IoTConnect will help to send those firmware updates to a particular device.
2.Manage Firmware
- Create new firmware using the firmware module in IoTConnect. You can upload the firmware file(s). Define hardware and software versions.
- By default, it’s in draft mode. You need to publish it once you are done with the setting of software and hardware versions.
- After publishing, you can upgrade the software version on the same firmware and publish the new firmware version.
- In the final step, you need to attach publish firmware to the device template that you want to use. For that, you can either create a new template or edit the existing template on the device section.
3.Send OTA Update
You can send an OTA update by selecting the firmware, software versions, and entity (with the option to include child entities as well).
There are below ways to do OTA updates
Schedule – You can schedule an OTA update by defining the date and time.
Force update – It will push firmware updates immediately.
Manage OTA Update on IoTConnect Device SDK
Once you implement device SDK on your device, we will have the callback method callbackMessage to receive the messages from the cloud. The device will be receiving device command and OTA firmware update information.
var callbackMessage = function callbackMessage(data){ if(data.cmdType == '0x01') { // Device command } else if(data.cmdType == '0x02') { // Firmware OTA command } }
When OTA firmware update sends from IoTConnect, the device will receive cmdType = ‘0x02’ with payload information (see Cloud to Device Data format for OTA) to get firmware update information. The developer needs to use those file URL and other information and perform his action on the device.
Also, Device SDK contains one method to send acknowledged about firmware. for more details visit client library and SDKs.
Retry Policy: If device offline/disconnected from the IotConnect then Device will not receive OTA command, But when its online again or connected with the IotConnect Platform will resent all OTA command to Device.