The SDK provides an in-app solution for Bluetooth Over-the-Air (OTA) services. It lets you upgrade the firmware of Bluetooth devices.
Dependent SDKs | Overview |
Bluetooth | The Breeze SDK is a mobile Bluetooth SDK that complies with standard specifications. It helps partners quickly integrate Bluetooth features into their mobile apps. Key features of the Breeze SDK include device discovery and connection, device communication, encrypted transmission, and large data transmission. |
API channel | Provides API channel capabilities and basic environment configuration information. |
Initialization
To initialize, perform the following steps.
Connect to the device using the Android Bluetooth SDK to obtain an IBreezeDevice instance.
Use the IBreezeDevice instance to call
BreezeHelper.getDeviceInfo()and obtain the deviceinfo.getDeviceInfo(breezeDevice,new IDeviceInfoCallback(){ void onDeviceInfo(DeviceInfo info){ mInfo = info; };Call
BreezeHelper.bindBreezeDevice()with DeviceInfo to bind the device to the current user. This call returns the iotID.BreezeHelper.bindBreezeDevice(breezeDevice, mInfo, new BindCallback(){ void onBindResult(BindResult result, int error){ if (null == error){ mIotId = result.iotId; } });
Usage
Configure an OTA task in the IoT Platform console. For more information, see Bluetooth Connection Development Guide.
Obtain an OTA instance.
Obtain an OTA object instance and initialize it. Be sure to release the resources when they are no longer needed. The device parameter is the Breeze connection object.
mBusiness = Factory.create(device); mBusiness.init();Check for firmware updates.
Check for new updates. The mIotId parameter is the ID that is returned when the device is successfully bound.
mBusiness.inquiryNewVersion(mIotId, new ILinkOTABusiness.IInquiryNewVersionCallback() { @Override public void onResult(boolean needUpgrade, String error, String result) { // Prompt the user to upgrade } });Start the OTA upgrade.
If a new OTA firmware version is available and the user agrees to the upgrade, you can call the following method to start the upgrade. The upgrade progress is reported through the
IOtaListenercallback.mBusiness.startUpgrade(iotId, false, ILinkOTABusiness.DEVICE_TYPE_BLE, new ILinkOTABusiness.IOtaListener() { @Override public void onNotification(int type, ILinkOTABusiness.IOtaError error) { Log.d(TAG, "onNotification type:" + type + " error:" + error);Stop the OTA upgrade.
You can call the following method to stop the upgrade. This is applicable when the OTA process is complete, regardless of success or failure, or when the user wants to stop the process.
mBusiness.stopUpgrade();Release OTA resources.
When the OTA process is no longer needed, be sure to release the OTA resources.
mBusiness.deInit();