Bluetooth OTA SDK

更新时间:
复制 MD 格式

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.

  1. Connect to the device using the Android Bluetooth SDK to obtain an IBreezeDevice instance.

  2. Use the IBreezeDevice instance to call BreezeHelper.getDeviceInfo() and obtain the deviceinfo.

    getDeviceInfo(breezeDevice,new IDeviceInfoCallback(){
      void onDeviceInfo(DeviceInfo info){
        mInfo = info;
    };
  3. 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

  1. Configure an OTA task in the IoT Platform console. For more information, see Bluetooth Connection Development Guide.

  2. 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();
  3. 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
                        }
                    });
  4. 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 IOtaListener callback.

    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);
  5. 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();
  6. Release OTA resources.

    When the OTA process is no longer needed, be sure to release the OTA resources.

    mBusiness.deInit();