Pegasus Pairing

Last Updated on : 2024-05-16 06:08:26download

Routers and Wi-Fi devices that have Pegasus pairing enabled can be used to pair other Wi-Fi devices.

Search devices for Pegasus pairing

Query devices that support Pegasus pairing

API description

/**
     * Get activated devices with lightning activation support.
     *
     * @param homeId Home id.
     * @return Device id list.
     */
ThingHomeSdk.getActivatorInstance().getSupportLightningActiveDevices(homeId)

Parameters

Parameter Description
homeId The home ID.

Search devices for Pegasus pairing

Parameters

Parameter Type Description
devIds List The list of devices that support Pegasus pairing.
serverTimeout long The timeout value for the server to search for devices to be paired. Unit: seconds.
clientTimeout long The timeout value for the client. Unit: seconds.
IThingLightningSearchListener Callback The callback.

Example

ThingHomeSdk.getActivatorInstance().newLightningActivator().startSearch(devList, serverTimeout, clientTimeout, new IThingLightningSearchListener() {
			@Override
			public void onSearchResponse(LightningSearchBean bean) {
				// The search result.
			}
		});

Stop searching

IThingLightningActivator.stopSearch();

Reset status of discovered devices

Parameter Type Description
devList List The list of discovered devices that support Pegasus pairing.
IThingLightningActivator.cancel(devList);

Get the token

Before the Pegasus 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.

Parameters

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

Example

ThingHomeSdk.getActivatorInstance().getActivatorToken(homeId, new IThingActivatorGetToken() {
	@Override
	public void onSuccess(String token) {

	}

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

	}
});

Start pairing

Parameters

Parameter Type Description
lightningSearchBeanList List The list of discovered devices that support Pegasus pairing.
token String The pairing token.
timeout Int The timeout value for pairing. Unit: seconds. Recommended value: 120.
IThingDevActivatorListener Callback The callback of the pairing result.

Example

ThingHomeSdk.getActivatorInstance()
		.newLightningActivator()
		.startActive(new ThingLightningDevActivatorBuilder()
				.setLightningSearchBeanList(lightningSearchBeans)
				.setTimeOut(60 * 1000)
				.setToken(token)
				.setListener(new IThingDevActivatorListener() {
					@Override
					public void onError(String errorCode, String errorMsg) {

					}

					@Override
					public void onActiveSuccess(DeviceBean devResp) {

					}
				}));

Stop pairing

IThingLightningActivator.stopActive();