
5 Pair devices
1
// Pairs the gateway .
2
TuyaBlueMeshActivatorBuilder tuyaBlueMeshActivatorBuilder
=
new
Tuya
3
BlueMeshActivatorBuilder
()
4
.
setWifiSsid
(
mSsid
)
5
.
setWifiPassword
(
mPassword
)
6
.
setSearchDeviceBeans
(
foundDevices
)
7
.
setVersion
(
"2.2 "
)
8
.
setBlueMeshBean
(
mMeshBean
)
9
.
setHomeId
(
" siteId "
)
10
.
setTuyaBlueMeshActivatorListener
(
new
ITuyaBlueMeshActivatorListener
11
() {
12
@Override
13
public
void
onSuccess
(
DeviceBean devBean
) {
14
// The callback that is used when a single device is paired .
15
L
.
d
(
TAG
,
" startConfig success "
);
16
}
17
@Override
18
public
void
onError
(
String
errorCode
,
String
errorMsg
) {
19
// The callback that is used when a single device failed to be paire
20
d
.
21
// The error code. See the list of pairing error codes .
22
L
.
d
(
TAG
,
" errorCode : "
+
errorCode
+
" errorMsg : "
+
errorMsg
);
23
}
24
@Override
25
public
void
onFinish
() {
26
// The callback that is used when all devices are paired .
27
}
28
});
29
ITuyaBlueMeshActivator iTuyaBlueMeshActivator
=
TuyaHomeSdk
.
getTuyaB
30
lueMeshConfig
().
newWifiActivator
(
tuyaBlueMeshActivatorBuilder
);
31
// Starts pairing .
32
iTuyaBlueMeshActivator
.
startActivator
();
33
// Stops pairing .
34
// iTuyaBlueMeshActivator . stopActivator ();
5.5 Pairing error codes
Error code
Description
13007
Failed to log in to a device.
13004
Failed to reset a device address.
13005
The upper limit of the number of device
addresses is reached.
13007
The SSID is empty.
15 / 31