English
English
简体中文
Contact Us
Register
Log In
layoutIndex

Device Pairing UI BizBundle

Last Updated on : 2022-09-02 07:56:23download

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 EZ mode 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.
IPC pairing in QR code mode An IPC scans the QR code on the app to get the pairing data.

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 to formulate 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).
Tuya mesh Tuya’s proprietary technology that enables Bluetooth devices to communicate over a mesh network.
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 Smart Life App SDK for Android into your project with Android Studio and add the framework of the UI BizBundle to your project.

  2. Configure the build.gradle file.

    dependencies {
    api 'com.tuya.smart:tuyasmart-bizbundle-device_activator:4.2.0-22'
    }
    
  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.tuya.**{*;}
    -dontwarn com.tuya.**
    

Implement features

Configure features

Item Field name Description Default value
Hotspot name settings <string name="ap_mode_ssid">SmartLife</string> The prefix of a device hotspot for pairing. SmartLife
Support for Bluetooth devices <bool name="is_need_ble_support">true</bool> Specifies whether Bluetooth devices can be paired. true
Support for Bluetooth mesh devices <bool name="is_need_blemesh_support">true</bool> Specifies whether Bluetooth mesh devices can be paired. 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. true
Whether the Wi-Fi EZ mode is 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. false

Make API requests

TuyaDeviceActivatorManager.startDeviceActiveAction(this, TuyaDeviceActivatorImpl.getInstance().getCurrentHomeId());

TuyaDeviceActivatorManager.setListener(new ITuyaDeviceActiveListener() {
            @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 pairing activity.
homeId The home ID. For more information, see Home Information Management.

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 pairing is not performed. You can implement this feature as needed.