Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private fun pairApMode() {
- println("pairApMode ==> SSID: $ssid, Password: $password, Token: $tokenPairing")
- try {
- val builder = ActivatorBuilder()
- .setSsid(ssid)
- .setContext(applicationContext)
- .setPassword(password)
- .setActivatorModel(ActivatorModelEnum.THING_AP)
- .setTimeOut(100)
- .setToken(tokenPairing)
- .setListener(object : IThingSmartActivatorListener {
- override fun onStep(step: String?, data: Any?) {
- println("onStep ==>$step $data")
- }
- override fun onActiveSuccess(devResp: DeviceBean?) {
- val arguments: HashMap<String, String?> = HashMap()
- arguments["deviceId"] = devResp?.devId
- arguments["name"] = devResp?.name
- methodChannel.invokeMethod("pairingSuccess", arguments)
- println("Pairing success, Connected to $deviceName")
- }
- override fun onError(
- errorCode: String?,
- errorMsg: String?
- ) {
- println("Activate error: $errorMsg - $errorCode")
- methodChannel.invokeMethod("pairingFailed", "$errorMsg - $errorCode")
- }
- }
- )
- val mTuyaActivator =
- ThingHomeSdk.getActivatorInstance().newActivator(builder)
- //Start configuration
- mTuyaActivator?.start()
- } catch (e: Exception) {
- println("pairApMode_Error: $e")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement