Wired Mode

Last Updated on : 2024-05-20 07:15:07download

A wired device connects to a router over an Ethernet cable. During the pairing process, users do not need to enter the hotspot name and password of the router. This topic describes the process to pair a Zigbee wired gateway.

Discover a device

The SDK provides the capability to discover the wired device pending pairing. The device must be connected to the same network as the mobile phone to enable pairing. Then, register the notification of data of the wired device. When the SDK receives the data broadcasted by the wired device, it forwards the data as a notification to the app.

API description

IThingGwSearcher mThingGwSearcher = ThingHomeSdk.getActivatorInstance().newThingGwActivator().newSearcher();
		mThingGwSearcher.registerGwSearchListener(new IGwSearchListener() {
			@Override
			public void onDevFind(HgwBean hgwBean) {

			}
		});

Parameters

Parameter Description
hgwBean The data entity of the discovered gateway.

Initialize pairing parameters

Device discovery supported

API description

IThingActivator mIThingActivator = ThingHomeSdk.getActivatorInstance().newGwActivator(
		new ThingGwActivatorBuilder()
			.setToken(token)
			.setTimeOut(timeout)
			.setContext(context)
			.setHgwBean(hgwBean)
			.setListener(new IThingSmartActivatorListener() {

					@Override
					public void onError(String errorCode, String errorMsg) {

					}

					@Override
					public void onActiveSuccess(DeviceBean devResp) {

					}

					@Override
					public void onStep(String step, Object data) {

					}
			}
		));

Parameters

Parameter Description
token The pairing token.
context The context to be set in activity.
timeout The timeout value of a pairing task. Default value: 100. Unit: seconds.
hgwBean The data entity of the discovered gateway.

Device discovery unsupported

API description

IThingActivator mIThingActivator = ThingHomeSdk.getActivatorInstance().newGwActivator(
		new ThingGwActivatorBuilder()
			.setToken(token)
			.setTimeOut(timeout)
			.setContext(context)
			.setListener(new IThingSmartActivatorListener() {

					@Override
					public void onError(String errorCode, String errorMsg) {

					}

					@Override
					public void onActiveSuccess(DeviceBean devResp) {

					}

					@Override
					public void onStep(String step, Object data) {

					}
			}
		));

Parameters

Parameter Description
token The pairing token.
context The context to be set in activity.
timeout The timeout value of a pairing task. Default value: 100. Unit: seconds.

Get a token

Before the wired device pairing process, the SDK must get a pairing token from the cloud in the networked state. The token is valid for 10 minutes and expires immediately after the device is paired. A new token must be generated if the device needs to be paired again.

ThingHomeSdk.getActivatorInstance().getActivatorToken(homeId,
		new IThingActivatorGetToken() {

			@Override
			public void onSuccess(String token) {

			}

			@Override
			public void onFailure(String s, String s1) {

			}
		});

Parameters

Parameter Description
homeId The home ID. For more information, see Home Management.

Call the pairing method

IThingActivator mIThingActivator = ThingHomeSdk.getActivatorInstance().newGwActivator(builder);
// Starts pairing.
mIThingActivator.start()
// Stops pairing.
mIThingActivator.stop()
// Exits the page and clears cached data.
mIThingActivator.onDestroy()