Skip to content

OTA Upgrade API

OTA Upgrade API Overview

FunctionDescription
Ql_iotCmdOtaRequest()Requests OTA Upgrade Plan from Developer Center.
Ql_iotCmdOtaAction()Configures OTA Upgrade Operations.
Ql_iotCmdOtaMcuFWDataRead()Reads firmware data stored in the device.

API Description

Ql_iotCmdOtaRequest

This function requests OTA upgrade plans from Developer Center.

Prototype

c
qbool Ql_iotCmdOtaRequest(quint32_t mode)

Parameter

  • Input
    • quint32_tmode: Whether extra file verification SHA256 information is needed.
      • 0: Not needed
      • 1: Needed

Return Value

  • True: Successful execution
  • False: Failed execution

NOTE

  • This function is supported in SDK version 2.8.2 and above.

Example

c
qbool ret = Ql_iotCmdOtaRequest(0);

Ql_iotCmdOtaAction

This function configures OTA upgrade operations when the device receives the upgrade task issued by Developer Center.

Prototype

c
qbool Ql_iotCmdOtaAction(quint8_t action)

Parameter

  • Input
    • quint8_taction: OTA upgrade operation.
      • 0: Refuse the upgrade
      • 1: Confirm the upgrade
      • 2: MCU starts downloading the next block of firmware data
      • 3: MCU reports the upgrading status

Return Value

  • True: Successful execution
  • False: Failed execution

NOTE

  • This function is supported in SDK version 2.3.3 and above.

Example

c
qbool ret = Ql_iotCmdOtaAction(1);

Ql_iotCmdOtaMcuFWDataRead

This function reads firmware data stored in the device.

Prototype

c
quint32_t Ql_iotCmdOtaMcuFWDataRead(quint32_t startAddr, quint8_t data[], quint32_t maxLen)

Parameter

  • Input
    • quint32_tstartAddr: Memory address to start reading firmware data from. Unit: byte.
    • quint8_tdata: Pointer to the buffer that stores data to be read.
    • quint32_tmaxLen: Length of data to be read.

Return Value

  • 0: Failed execution
  • > 0: Length of actually read data

NOTE

  • This function is supported in SDK version 2.3.3 and above.

Example

c
quint8_t readBuf[1024];
quint32_t ret = Ql_iotCmdOtaMcuFWDataRead(0,readBuf,sizeof(readBuf));