Wi-Fi AP Pairing

1. Overview

This document describes how to use the Device Pairing SDK (with UI) and Device Pairing SDK (without UI) for Wi-Fi AP pairing.

2. Prerequisites

  1. Complete preparation
  2. Complete environment build
  3. Complete Device Pairing SDK (with UI) or Device Pairing SDK (without UI) integration

3. Usage

3.1 Pairing flow

Wi-Fi AP onboarding means that after the device enables hotspot mode, the SDK connects to the device hotspot, sends pairing information to the device, the device connects to the Aqara cloud using the Wi-Fi account and password in the pairing information, and finally completes activation.

3.2 Device Pairing SDK (with UI)

3.2.1 Navigate to the pairing page for a specific device

Kotlin

LumiAccessSDKManager.getInstance().gotoAccessConfigModule(
    this,
    "lumi.gateway.agl008", // deviceModel; see the supported device list
    object : LumiResultCallBack {
        override fun fail(errorCode: Int?, errorMessage: String?) {
            // Pairing failed
        }

        override fun success(activity: WeakReference<Activity>, message: String?) {
            // Pairing succeeded. You can close the pairing page at an appropriate time:
            activity.get()?.finish()
        }
    }
)

Java

LumiAccessSDKManager.getInstance().gotoAccessConfigModule(
        this,
        "lumi.gateway.agl008",
        new LumiResultCallBack() {
            @Override
            public void fail(@Nullable Integer errorCode, @Nullable String errorMessage) {
                // Pairing failed
            }

            @Override
            public void success(@NonNull WeakReference<Activity> activity, @Nullable String message) {
                // Pairing succeeded. You can close the pairing page at an appropriate time:
                Activity page = activity.get();
                if (page != null) {
                    page.finish();
                }
            }
        }
);

Parameter description

Field Data type Description How to obtain
deviceModel String Device model value See Device Pairing SDK Supported Device List

3.3 Device Pairing SDK (without UI)

3.3.1 Obtain BindKey

The third-party app must request the cloud API itself. For details, see API documentation

3.3.2 Wi-Fi scan

WifiScanner wifiScanner = new WifiScanner(this);
wifiScanner.findDeviceByWifi(2000L)
        .onTerminateDetach()
        .as(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(this)))
        .subscribe(new Consumer<List<android.net.wifi.ScanResult>>() {
            @Override
            public void accept(List<android.net.wifi.ScanResult> scanResults) throws Exception {

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

            }
        });

Parameter description

Field Data type Description Notes
intervalTime long Interval How often (in milliseconds) the SDK callbacks with results

3.3.3 Connect to the device Wi-Fi hotspot and send pairing information

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

AccessAPManager manager = new AccessAPManager.WifiAccessBuilder()
        .setAccessInfo(accessConfigBean)
        .setDeviceAp("Device hotspot ssid")
        .setAccessMode(AccessAPManager.WifiAccessMode.ACCESS_MODE_UDP)
        .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 pairing
manager.startAccess();

// Recycle resources at an appropriate time; otherwise pairing data may be cached and cause failures
manager.onDestroy();

Parameter description

Field Data type Description How to obtain
ssid String Pairing Wi-Fi name Obtained from Wi-Fi scan
password String Pairing Wi-Fi password Entered by the user
coapServer String Device onboarding domain (which server the device joins) Obtained via API; see Aqara Developer Platform
bindKey String Unique device onboarding identifier The third-party app requests the API itself
deviceAp String SSID of the device Wi-Fi hotspot Obtained from Wi-Fi scan
accessMode String Device onboarding type See values below

accessMode values

Value Data type Description
ACCESS_MODE_UDP enum Transmit via UDP; see appendix Supported onboarding device list
ACCESS_MODE_TCP enum Transmit via TCP; see appendix Supported onboarding device list
ACCESS_MODE_HTTP enum Transmit via HTTP; see appendix Supported onboarding device list
lumi LogoCopyright © 2023 Lumi United Technology Co., Ltd. all right reserved,powered by GitbookFile Modify: 2026-08-11 17:03:05

results matching ""

    No results matching ""