Pair with QR Code on Device

Last Updated on : 2023-09-20 06:51:49download

This method only applies to devices that are connected to the internet.

Pairing process

DeviceHTTPS DNSMQTTAppCloudPower on device andconnect to internetReset device to get itready for pairingSelect HTTP DNS and requestdomain name of mqttsUrlReturn domain name ofmqttsUrlUse UUID to connect to MQTTScan QR code on deviceGet device UUID and requesttoken for pairingPoll for device to be pairedbased on tokenPush token and regionPass pairing data to deviceRequest device activationDevice activatedDevice activated and devicelist returnedDeviceHTTPS DNSMQTTAppCloudProcess of pairing with QR code on device

Query device UUID

// The URL obtained after the device QR code is scanned.
ThingHomeSdk.getActivatorInstance().deviceQrCodeParse("url", new IThingDataCallback<QrScanBean>() {
            public void onSuccess(QrScanBean result) {
                if(result != null){
                    // Get uuid from result.actionData. This parameter will be used as the request parameter in the subsequent pairing process.


            public void onError(String errorCode, String errorMessage) {
                // errorCode:QR_PROTOCOL_NOT_RECOGNIZED protocol is unknown.


Initialize pairing parameters

ThingQRCodeActivatorBuilder builder = new ThingQRCodeActivatorBuilder()
        .setListener(new IThingSmartActivatorListener() {

                public void onError(String errorCode, String errorMsg) {


                public void onActiveSuccess(DeviceBean devResp) {


                public void onStep(String step, Object data) {



Parameter Description
uuid The UUID that is returned after a device QR code is scanned.
homeId The home ID. For more information about how to get the value, see Home Management.
timeout The timeout value of a pairing task. Default value: 100. Unit: seconds.

Call the pairing method

IThingActivator mThingActivator = ThingHomeSdk.getActivatorInstance().newQRCodeDevActivator(builder);
// Starts pairing.
// Stops pairing.
// Destroys the pairing task.