Device Pairing UI BizBundle

Last Updated on : 2024-03-28 06:33:35download

Commercial Lighting Device Pairing UI BizBundle is used to implement pairing guidance and smart device activation. It applies to multiple common types of smart devices, such as Wi-Fi devices, Zigbee devices, Bluetooth devices, and devices that support QR code scanning like General Packet Radio Service (GPRS) and narrowband Internet of Things (NB-IoT) devices.

Device types

Wi-Fi device pairing

Wi-Fi smart devices can be paired and connected to cloud services in two modes: Wi-Fi Easy Connect (EZ) mode and access point (AP) or hotspot mode. IP cameras (IPCs) can be paired after QR code scanning.

Term Description
Wi-Fi Easy Connect Also known as the EZ mode. This pairing mode is implemented through the following steps:
1. The app encapsulates the pairing data into the specified section of an IEEE 802.11 packet and sends the packet to the network.
2. The Wi-Fi module of a smart device runs in promiscuous mode and listens for and captures all packets over the network.
3. The Wi-Fi mode parses the packets that carry the pairing data from the app into the data format specified by the protocol.
AP mode Also known as the hotspot mode. A mobile phone acts as a station (STA) and connects to the hotspot of a smart device. Then, both devices are paired to establish a socket connection between them and exchange data through the specified ports.

Zigbee device pairing

Zigbee gateways and sub-devices can be paired.

Term Description
Zigbee gateway The device that integrates the coordinator with Wi-Fi features on a Zigbee network. The gateway is responsible for formulating the Zigbee network and store data.
Zigbee sub-device A router or a terminal on a Zigbee network. Each Zigbee sub-device is responsible to forward data or respond to terminal control commands.

Bluetooth device pairing

Tuya provides the following Bluetooth solutions.

Term Description
Bluetooth Low Energy (LE) A peer-to-peer connection is created between a Bluetooth or Bluetooth LE device and a mobile phone.
Bluetooth mesh Enable many-to-many (m:m) device communications over a mesh network released by Bluetooth Special Interest Group (SIG).
Combo devices The devices that support Bluetooth and Wi-Fi combo can be paired over either Bluetooth or Wi-Fi.

QR code pairing

A smart device that supports this pairing mode is connected to Tuya’s cloud services immediately after power on. The app can be used to scan the QR code on the device to implement cloud-based device activation and binding. The QR code must comply with Tuya’s QR code rules. For more information, contact Tuya’s account manager.

Term Description
GPRS devices Smart devices that apply GPRS technologies to connect to the network and access cloud services.
NB-IoT devices Smart devices that apply NB-IoT technologies.

Pairing by auto discovery

Tuya provides efficient pairing features on top of Tuya’s generic pairing technologies for smart devices.

Integrate with the UI BizBundle

  1. Create a project.

    Integrate Commercial Lighting App SDK for Android into your project with Android Studio and add the UI BizBundle to your project.

  2. Configure the build.gradle file.

    dependencies {
    	api enforcedPlatform("com.thingclips.smart:thingsmart-BizBundlesBom:2.8.0-bizbundle-lamp-2.8.0.27")
            api ("com.thingclips.smart:thingsmart-bizbundle-lamp_device_activator")
    }
    
  3. Obfuscate the code.

    #fastJson
    -keep class com.alibaba.fastjson.**{*;}
    -dontwarn com.alibaba.fastjson.**
    
    #rx
    -dontwarn rx.**
    -keep class rx.** {*;}
    -keep class io.reactivex.**{*;}
    -dontwarn io.reactivex.**
    -keep class rx.**{ *; }
    -keep class rx.android.**{*;}
    
    #fresco
    -keep class com.facebook.drawee.backends.pipeline.Fresco
    -keep @com.facebook.common.internal.DoNotStrip class *
    -keepclassmembers class * {
    @com.facebook.common.internal.DoNotStrip *;
    }
    
    #tuya
    -keep class com.thingclips.**{*;}
    -dontwarn com.thingclips.**
    

Implement features

Configure features

Item Field name Description
Hotspot name settings <string name="ap_mode_ssid">SmartLife</string> The list of hotspot name prefixes supported for AP pairing. Default value: SmartLife.
Support for Bluetooth devices <bool name="is_need_ble_support">true</bool> Specifies whether Bluetooth devices can be paired. Default value: true.
Support for mesh devices <bool name="is_need_blemesh_support">true</bool> Specifies whether mesh devices can be paired. Default value: true.
Support for QR code scanning <bool name="is_scan_support">true</bool> Specifies whether the app can be used to scan the QR code on a device and start pairing. Default value: true.
Wi-Fi EZ mode supported by automatic discovery <bool name="is_config_activator_ez">false</bool> Specifies whether smart devices that support the EZ mode can be automatically discovered. Default value: false.

Make API requests

ThingDeviceActivatorManager.INSTANCE.startDeviceActiveAction(this);

ThingDeviceActivatorManager.INSTANCE.addListener(new IThingDeviceActiveListener() {

            @Override
            public void onDevicesAdd(List<String> list) {

            }

            @Override
            public void onRoomDataUpdate() {

            }

            @Override
            public void onOpenDevicePanel(String s) {

            }

            @Override
            public void onExitConfigBiz() {

            }
        });

Request parameters

Parameter Description
activity The activity.
homeId The relation ID corresponding to the area where the device is paired. For how to get the relation ID, see Get a relation ID (gid) of an area.

Response parameters

Parameter Description
devIds The success callback. A list of paired device IDs is returned.
updateRoomData Indicates whether room device details are updated.
onOpenDevicePanel Indicates whether a certain panel can be opened. You can implement this feature as needed.
onExitConfigBiz Indicates whether to exit the pairing service if the pairing is not performed. You can implement this feature as needed.