Last Updated on : 2025-07-03 07:06:25download
The OTA update process of the central control device works the same way as the gateway. For more information, see Gateway OTA Update.
Function prototype | OPERATE_RET tuya_dev_upgrade_check_init(VOID) |
---|---|
Function description | Start a timer to periodically check for new versions. |
Parameter | VOID |
Return value | OPERATE_RET, 0: Success; Others: Failure. See error codes for more details. |
Detailed description | - |
Function prototype | OPERATE_RET tuya_dev_upgrade_check_start(VOID) |
---|---|
Function description | Check if there is a new version. |
Parameter | VOID |
Return value | OPERATE_RET, 0: Success; Others: Failure. See error codes for more details. |
Detailed description | - |
Function prototype | OPERATE_RET tuya_dev_upgrade_get_info(TY_UPGRADE_INFO_S *info) |
---|---|
Function description | Obtain upgrade firmware information. |
Parameter | info: Upgrade firmware information information structure. |
Return value | OPERATE_RET, 0: Success; Others: Failure. See error codes for more details. |
Detailed description | - |
Function prototype | OPERATE_RET tuya_dev_upgrade_confirm_report(VOID) |
---|---|
Function description | Upgrade immediately. |
Parameter | VOID |
Return value | OPERATE_RET, 0: Success; Others: Failure. See error codes for more details. |
Detailed description | - |
Example
STATIC INT_T __new_version_cb(IN CONST TY_UPGRADE_INFO_S *p_ug_info)
{
PR_DEBUG("new version callback flag:%d, version:%s, size:%d, msg:%s", p_ug_info->flag, p_ug_info->version, p_ug_info->file_size, p_ug_info->msg);
if (p_ug_info->flag > 0) {
PR_DEBUG("new version found, please update");
OPERATE_RET ret = tuya_dev_upgrade_confirm_report();
if (ret != OPRT_OK) {
PR_ERR("tuya_dev_upgrade_confirm_report err:%d", ret);
return ret;
}
} else {
PR_DEBUG("current version is the latest");
}
return OPRT_OK;
}
VOID test_ctrl_center_update()
{
OPERATE_RET ret = OPRT_OK;
ret = tuya_dev_upgrade_check_init();
if (ret != OPRT_OK) {
PR_ERR("tuya_dev_upgrade_check_init err:%d", ret);
return;
}
ret = tuya_home_ctrl_subscribe_new_version(__new_version_cb);
if (ret != OPRT_OK) {
PR_ERR("tuya_home_ctrl_subscribe_new_version err:%d", ret);
return;
}
return;
}
tuya_dev_upgrade_check_init
does not have a reentrant mechanism and can only be called once after the program starts. The callback is registered via tuya_home_ctrl_subscribe_new_version
.tuya_home_ctrl_subscribe_new_version
is called multiple times, the callback function passed in the last call takes effect.Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback