wifi设备配网过程中,使用
Code: Select all
val builder = ActivatorBuilder()
.setSsid(strSsid)
.setContext(v.context)
.setPassword(strPassword)
.setActivatorModel(ActivatorModelEnum.THING_EZ)
.setTimeOut(100)
.setToken(token)
.setListener(object : IThingSmartActivatorListener {
@Override
override fun onStep(step: String?, data: Any?) {
Log.i(TAG, "$step --> $data")
}
override fun onActiveSuccess(devResp: DeviceBean?) {
Log.i(TAG, "Activate success")
}
override fun onError(
errorCode: String?,
errorMsg: String?
) {
}
}
)
val mTuyaActivator =
ThingHomeSdk.getActivatorInstance().newMultiActivator(builder)
//Start configuration
mTuyaActivator.start()
而同时 在注册registerHomeStatusListener监听也能收到设备新增消息。
Code: Select all
ThingHomeSdk.newHomeInstance(spaceId)
.registerHomeStatusListener(new IThingHomeStatusListener() {
@Override
public void onDeviceAdded(String devId) {
L.d(TAG, "onDeviceAdded");
listener.onDeviceAdded(devId);
}
...
})
onDeviceAdded 回调有时候会快于onActiveSuccess 的回调,onDeviceAdded 是可以当做配网成功的吗?