OTA upgrade process reference:
The following is the OTA upgrade process for watches, bracelets, and rings. Note: The example for the ring is different.
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 Device Information, "${fwVersion1}.${fwVersion2}.${fwVersion3}".
Call the OTA upgrade interface (server-side 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 this 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.
The SDK has only one method for transferring all files, reference:
Example 1 (Watch, Bracelet):
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
}
}
}
)
Example 2 (Ring):
- Actively disconnect the Bluetooth connection.
- Mark OTA mode.
- Execute OTA file transfer (same as watch, bracelet).
// 1. Disconnect Bluetooth connection
sdk.ble.cancelConnect(macAddress) { ... }
// 2. Mark OTA mode
sdk.bridge.markOtaMode(macAddress = macAddress, platform = sdk.device.platform, deviceId = sdk.device.deviceId) {
_startTransfer()
}
// 3. Execute OTA file transfer (same as watch, bracelet), the code below is the same as Example 1
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
}
}
}
)