Appearance
OTA Upgrade API
OTA Upgrade API Overview
Function | Description |
---|---|
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_t
mode
: Whether extra file verification SHA256 information is needed.- 0: Not needed
- 1: Needed
- quint32_t
Return Value
True
: Successful executionFalse
: 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_t
action
: OTA upgrade operation.0
: Refuse the upgrade1
: Confirm the upgrade2
: MCU starts downloading the next block of firmware data3
: MCU reports the upgrading status
- quint8_t
Return Value
True
: Successful executionFalse
: 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_t
startAddr
: Memory address to start reading firmware data from. Unit: byte. - quint8_t
data
: Pointer to the buffer that stores data to be read. - quint32_t
maxLen
: Length of data to be read.
- quint32_t
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));