Start OTA
Upgrade through the unified capability
import {
GizOTAProgressData,
GizOTAFirmwareType,
} from '@gizwits/smart-sdk';
import { hilog } from '@kit.PerformanceAnalysisKit';
await device.bleCapability.startUpgrade(
device,
GizOTAFirmwareType.MCU,
(progress: GizOTAProgressData): void => {
hilog.info(
0x0000,
'GizwitsSample',
'BLE OTA event=%{public}s progress=%{public}d%%',
progress.event,
progress.percentage
);
}
);startUpgrade() checks again, downloads firmware, and transfers it over BLE. It throws if no update exists, the device lacks OTA support, or another task is running for the same device.
Use the low-level OTA manager
Advanced integrations can obtain GizBleOTAManager:
const otaManager = GizBluetoothManager.getOtaManager(device);
await otaManager.startUpgrade(GizOTAFirmwareType.MCU, progressHandler);Most applications should continue using device.bleCapability for a consistent capability API.
⚠️
Keep the app in the foreground, maintain network connectivity and BLE range, and never start concurrent OTA tasks for the same device.