Skip to content

OTA Upgrade API

API Overview

FunctionDescription
Qth_otaRequest()Requests OTA upgrade plans.
Qth_otaPlanConfirm()Confirms OTA upgrade plans.

API Description

Qth_otaRequest

This function requests OTA upgrade plans for the device from Developer Center. When the device goes online, it will actively request an OTA upgrade. If the device needs to check for OTA upgrade tasks at other times, call this function to request OTA upgrade plans.

Prototype

c
oprt_ret Qth_otaRequest(void);

Parameter

  • Input Parameter
    • None
  • Return Value
    • OPRT_OK: Successful execution
    • Other values: Failed execution. See Error Code List for details.

Example

c
oprt_ret ret = Qth_otaRequest();
if (OPRT_OK != ret)
{
    Quos_logPrintf(APPS_OPEN, LL_ERR, "ota request fail ret:%d", ret);
    return ret;
}

Qth_otaPlanConfirm

This function confirms OTA upgrade plans, including accepting or rejecting the plan, when Developer Center issues an OTA upgrade plan. This function is not used if Qth_otaPlanCb_f() has been registered.

Prototype

c
oprt_ret Qth_otaPlanConfirm(quint8_t action);

Parameter

  • Input Parameter

    • quint8_t action: Operation on the OTA upgrade plan.
      ValueDescription
      0Accept the upgrade.
      1Reject the upgrade.
  • Return Value

    • OPRT_OK: Successful execution
    • Other values: Failed execution. See Error Code List for details.

Example

c
void otaPlanExCb(Qth_otaPlan_t *planList, quint16_t count)
{
    if(QTH_OTA_TYPE_FOTA == (qint32_t)planList[0].type)
    {
        Qth_otaPlanConfirm(1);
    }
}

Error Code List

Enumeration ValueHexadecimalDecimalDescription
OPRT_OK-0x0000-0Successful execution.
OPRT_COM_ERROR-0x0001-1General error.
OPRT_INVALID_PARM-0x0002-2Invalid parameter.
OPRT_MALLOC_FAILED-0x0003-3Memory allocation failed.
OPRT_NOT_SUPPORTED-0x0004-4Not supported.
OPRT_NOT_FOUND-0x0005-5Object not found.
OPRT_INDEX_OUT_OF_BOUND-0x0006-6Index out of bounds.
OPRT_EXCEED_UPPER_LIMIT-0x0007-7Exceed upper limit.
OPRT_NOT_EXIST-0x0008-8Not exist.
OPRT_QTH_OTA_REQUEST_FAILED-0x1a00-6656Failed to request an OTA upgrade.
OPRT_QTH_OTA_ID_NOT_TASK-0x1a01-6657No OTA upgrade task is in progress for the component.