Last Updated on : 2024-05-27 06:01:13download
A wired device connects to a router over an Ethernet cable. During the pairing process, users do not need to enter the name and password of the access point. This topic describes how to pair a wired device, using the wired Zigbee gateway as an example.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
mode |
ActivatorMode |
Yes | The pairing mode. |
Example
WiredActivator wiredActivator = (WiredActivator) ActivatorService.activator(ActivatorMode.Wired);
Before pairing a wired device, the SDK requests a pairing token valid for 10 minutes from the cloud. This token will become invalid immediately after the pairing is successful. To pair the device again, you must request a new token.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
assetId | String | Yes | The ID of the specified asset. |
callback | IndustryDataCallBack | Yes | The callback. |
Example
// Get the asset activation token.
ActivatorService.activatorToken("assetId", new IndustryDataCallBack<String>() {
@Override
public void onSuccess(String s) {
Log.d(TAG, "onSuccess: " + s);
}
@Override
public void onFailure(@NonNull String s, @NonNull String s1) {
Log.d(TAG, "onFailure: " + s);
}
});
IDiscoveryListener
to listen for scanning resultParameters
IWiredDevice
data model
Parameter | Type | Required | Description |
---|---|---|---|
getIP() | String | Yes | Get the IP address of the device. |
getGWId() | String | Yes | Get the ID of the gateway. |
getProductKey() | String | Yes | Get the product key for the device. |
IDiscovery iDiscovery = ActivatorService.discovery(DiscoveryMode.WIRED);
iDiscovery.setListener(new IDiscoveryListener() {
@Override
public void didDiscover(@NonNull IDiscoveryDevice iDiscoveryDevice) {
if (iDiscoveryDevice instanceof IWiredDevice){
((IWiredDevice) iDiscoveryDevice).getIP();
((IWiredDevice) iDiscoveryDevice).getGWId();
((IWiredDevice) iDiscoveryDevice).getProductKey();
}
}
});
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
gwDevice | IWiredDevice | Yes | Pass in the gateway object. |
time | int | Yes | Set the timeout. |
token | String | Yes | Set the token. |
Example
WiredActivatorParams wiredActivatorParams = new WiredActivatorParams.Builder()
.setGWDevice(gwDevice)
.setTimeout(time)
.setToken("token")
.build();
wiredActivator.setParams(wiredActivatorParams);
IActivatorListener
to listen for pairing resultParameters
Parameter | Type | Required | Description |
---|---|---|---|
listener | IActivatorListener | Yes | Listen for the callback. |
Example
wiredActivator.setListener(new IActivatorListener() {
@Override
public void onSuccess(@Nullable IDevice iDevice) {
Log.d(TAG, "onSuccess: ");
}
@Override
public void onError(@NonNull String s, @NonNull String s1) {
Log.d(TAG, "onError: " + s);
}
});
This method starts device pairing.
Example
wiredActivator.start();
This method stops device pairing.
Example
wiredActivator.stop();
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback