Bluetooth

1. Overview

This article mainly introduces how to use the Device Pairing SDK (With UI) and Device Pairing SDK (Without UI) by Bluetooth.

2. Preconditions

  1. Confirm completion Preparation
  2. Confirm the completion of Environment Build
  3. Complete Device Pairing SDK (With UI) or Device Pairing SDK (without UI) integration

3. Use

3.1 Pairing Process

Device Pairing by Bluetooth means that after the App discovers the device through Bluetooth, it connects to the device through Bluetooth, and sends the pairing information to the device, and finally completes the device registration, binding and other operations.

3.2 Device Pairing SDK (With UI), API call

3.2.1 Jump to the Device Pairing device list page

Jump to the select device list page, which lists all the devices supported by the current SDK.

   LMAccessSDKManager.Companion.getInstance()
                .gotoAccessListPage(
                        this,
                        "homeId",
                        "roomId",
                        "coapServer",
                        new LumiResultCallBack() {
                            @Override
                            public void success(@NonNull WeakReference<Activity> weakReference, @Nullable String s) {

                            }

                            @Override
                            public void fail(@Nullable Integer integer, @Nullable String s) {

                            }
                        }
                );

参数说明

Field Type of data Describe Access channel
homeId String Home location Interface acquisition, see Aqara Developer Platform
roomId String Room location Interface acquisition, see Aqara Developer Platform
coapServer String Device network domain name (which server the device connects to) Interface acquisition, see Aqara Developer Platform

3.2.2 Jump to the specified device configuration page

LMAccessSDKManager.Companion.getInstance()
        .gotoAccessConfigModule(
                this,
                "deviceModel",
                "homeId",
                "roomId",
                "coapServer",
                new LumiResultCallBack() {
                    @Override
                    public void success(@NonNull WeakReference<Activity> weakReference, @Nullable String s) {

                    }

                    @Override
                    public void fail(@Nullable Integer integer, @Nullable String s) {

                    }
                }

        );

Parameter Description

Field Type of data Describe Access channel
deviceModel String Device model value See appendix List of supported network access devices
homeId String Home location Interface acquisition, see Aqara Developer Platform
roomId String Room location Interface acquisition, see Aqara Developer Platform
coapServer String Device network domain name (which server the device connects to) Interface acquisition, see Aqara Developer Platform

3.3 Device Pairing SDK (without UI)

3.3.1 Get bindKey

The third-party app needs to implement the interface request by itself, please refer to Aqara Developer Platform

3.3.2 Bluetooth Discovery

BleScanner bluetoothLeScanner = new BleScanner(this);
bluetoothLeScanner.findDeviceByBle(2000L)
        .onTerminateDetach()
        .as(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(this)))
        .subscribe(new Consumer<List<ScanResult>>() {
            @Override
            public void accept(List<ScanResult> scanResults) throws Exception {

            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {

            }
        });

Parameter Description

Field Type of data Describe Description
intervalTime long Intervals How many milliseconds the SDK calls back the result

3.3.3 Send distribution network information

AccessConfigBean accessConfigBean = new AccessConfigBean(
        "ssid",
        "password",
        "coapServer",
        "bindKey"
);

AccessBleManager manager = new AccessBleManager.BLEAccessBuilder()
        .setAccessInfo(accessConfigBean)
        .setAccessMode(AccessBleManager.BleAccessMode.ACCESS_MODE_BLE_SUB_DEVICE)
        .setBleMac("deviceBleMac")
        .setAccessListener(new IAccessListener() {
            @Override
            public void connectSuccess() {

            }

            @Override
            public void accessResult(@Nullable String s) {

            }

            @Override
            public void accessFail(int i, @Nullable String s) {

            }
        })
        .build(this);

//Start to configure the network
manager.startAccess();

//Call resource recycling at the appropriate time, otherwise there may be data caching in the Device Pairing, resulting in unsuccessful problems.
manager.onDestroy();

Parameter Description

Field Type of data Describe Access channel
ssid String Distribution Network Wi-Fi Name Wi-Fi Search Acquisition
password String Distribution Network Wi-Fi Password User input
coapServer String Device access server Interface acquisition, see Aqara Developer Platform
bindKey String Device network unique identifier The third-party app requests the interface to obtain by itself
bleMac String Device bluetooth address Get via Bluetooth search
accessMode String Device network type For details, please refer to the value below

accessMode value

Value Type of data Describe
ACCESS_MODE_GATEWAY enum Bluetooth hub, see appendix Supported network access device list
ACCESS_MODE_BLE_SUB_DEVICE enum Bluetooth child device, see appendix Supported network access device list
ACCESS_MODE_BLE_ZIGBEE_SUB_DEVICE enum For Bluetooth/Zigbee dual- child device, see the appendix List of supported network access devices
Copyright © 2023 Lumi United Technology Co., Ltd. all right reserved,powered by GitbookFile Modify: 2024-09-27 21:51:47

results matching ""

    No results matching ""