Last Updated on : 2024-06-24 10:17:12download
An OTA update is the wireless delivery of new software, firmware, or other data to connected smart devices. It can be used to fix bugs and add features.
Three update methods are available based on how an update is notified.
Update notification: Users are prompted whether to install an update when they open a device panel.
Forced update: Users receive a firmware update notification and have no option but to update the firmware.
Check for updates: Users will not receive a firmware update notification, but need to manually check for new updates.
Automatic update is determined by the auto update setting on the Developer Platform and the app together.
Automatic update is determined by the auto update setting on the Tuya Developer Platform and the app together.
tuya_iot_wifi_api.h
base_event_info.h
tuya_svc_upgrade.h
Typically, the development framework processes the OTA update for the main network firmware, without any action required from you. Alternatively, you can take care of the OTA update process if needed.
Framework manages updates for main network firmware
Create firmware on the Developer Platform and obtain the firmware key.
When calling the device initialization API, specify the firmware key in the input parameter.
To get notified of the progress of the update, you can subscribe to OTA events.
// ota
#define EVENT_OTA_PROCESS_NOTIFY "ota.process"
#define EVENT_OTA_FAILED_NOTIFY "ota.failed"
#define EVENT_OTA_FINISHED_NOTIFY "ota.finished"
Compile the project to obtain the update file with UG in its name.
Upload firmware and deploy an OTA update task on the Developer Platform.
You manage updates for main network firmware
This function is required only when you manage the main network firmware update on your own. Otherwise, the framework will automatically register the handler to process and write the update data to the correct location.
/**
* @brief Register pre-precess handler to replace the default one
*
* @param[in] pre_ug_cb The new handler
*/
VOID tuya_svc_upgrade_register_pre_cb(DEV_UPGRADE_PRE_INFORM_CB pre_ug_cb);
If you manage updates for the main network firmware on your own, call this function in the main network firmware update callback. Otherwise, calling this function is not necessary.
/**
* @brief Start to download the specific firmware
*
* @param[in] dev_id ID of sub-device, or NULL for GW
* @param[in] fw Firmware info to download
* @param[in] get_file_cb Callback to transfer data while downloading
* @param[in] pri_data Private data
* @param[in] upgrd_nofity_cb Callback when update is completed or an error occurs
* @param[in] upload_upgrade_percent Upload update percent or not
* @param[in] download_buf_size Buffer size allocated for OTA
*
* @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
*/
OPERATE_RET tuya_svc_upgrade_start(CONST CHAR_T *dev_id,
CONST FW_UG_S *fw,
CONST GET_FILE_DATA_CB get_file_cb,
VOID *pri_data,
CONST UPGRADE_NOTIFY_CB upgrd_nofity_cb,
CONST BOOL_T upload_upgrade_percent,
CONST UINT_T download_buf_size);
If you manage updates for the main network firmware on your own, see the following example.
After downloading the Networked Product Development Framework, you can find the example code for all features in the tuyaos_demo_examples
folder under the apps
directory. See the code in examples/service_ota/example_main_ota_custom.c
. For the usage of the example code, see TuyaOS Example Collection.
The reasons are broken down into two categories, firmware download issues and installation issues. Most update failures occur due to download issues. If the update progress is reported as above 90%, it can be considered that the firmware download is complete. Otherwise, it is not.
Device network issues
HMAC verification fails.
Device certificate issue
Proxy server issue
Cloud storage issue
If the updates have been released
Check if you have configured an update rule and confirm whether the target device meets this rule.
If the updates are not released
Check if the target device has been included in the testing allowlist.
If the device version on the allowlist page is shown as unknown, it could lead to a failure in detecting updates. Confirm each possible reason below.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback