OTA upgrade process reference:
1. Preconditions:
The device power is greater than 30% (this value is defined according to the specific product, and the APP can be customized, such as 40%, as long as it is greater than the minimum power limit of the firmware)
The device needs to be connected
2. Check the upgrade
- According to the device firmware version information https://idoosmart.github.io/Native_GitBook/en/doc/IDODeviceInfo.html, "${fwVersion1}.${fwVersion2}.${fwVersion3}"
Call OTA according to the interface (server implementation)
- After determining that there is an upgrade, download the file to the device according to the ota file address returned by the server
3. Execute the upgrade
Call the file transfer interface and transfer the ota file to the device
After the transfer is completed, the device will automatically enter the upgrade state, and the Bluetooth connection will be disconnected during the period
The device will restart after the upgrade is completed, and the upgrade process ends
Example reference:
Device OTA upgrade is not complicated, you can think of it as just a process of transferring a file to the device
SDK has only one method for transferring all files, reference:
https://idoosmart.github.io/Native_GitBook/en/doc/transfer/IDOFileTransfer.html
The following code in the example is the firmware upgrade:
var items = mutableListOf<IDOTransBaseModel>()
// Firmware
items.add(IDOTransNormalModel(fileType: IDOTransType.FW , filePath: "/xx/xx/xx.fw[bin|zip]", fileName: "xx"))
// Call transfer
val cancelable = sdk.transfer.transferFiles(
items, cancelPre,
{ currentIndex, totalCount, currentProgress, totalProgress ->
print("Transmitting ${currentIndex + 1}/$totalCount...")
},
{ currentIndex: Int, status: IDOTransStatus, errorCode: Int?, finishingTime: Int? ->
if (status != IDOTransStatus .FINISHED || errorCode != 0) {
print("Transmission failed: $errorCode")
}
},
{resultList-> resultList.forEach {
if (it){
//Transmission successful
}else{
//Transfer failed
}
}})