Last Updated on : 2024-05-14 02:38:21download
A smart device scans the QR code generated by the mobile app to get the Wi-Fi credentials and token. It then connects to the router and gets activated in the cloud. This pairing method is typically used for devices with a camera and Wi-Fi module, such as smart cameras and doorbells.
Before the pairing process, the app 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.
ThingActivatorDeviceCoreKit.getActivatorInstance()
.getActivatorToken(spaceId,IThingActivatorGetToken)
Parameter description
Parameters | Description |
---|---|
spaceId | The ID of the home with which the device is bound. |
callback | The callback for the result. |
val mThingActivator =
ThingActivatorDeviceCoreKit.INSTANCE.getActivatorInstance().newCameraDevActivator(new ThingCameraActivatorBuilder()
.setSsid(ssid)
.setPassword(pass)
.setToken(token)
.setListener(object : IThingSmartCameraActivatorListener {
override fun onQRCodeSuccess(qrcodeUrl: String) {
}
override fun onError(errorCode: String, errorMsg: String) {
}
override fun onActiveSuccess(devResp: DeviceBean) {}
})
)
mThingActivator.createQRCode()
Parameter description
Parameters | Description |
---|---|
ssid | The name of the target Wi-Fi network. |
password | The password of the target Wi-Fi network. |
token | The pairing token. |
listener | The callback for the result. |
val builder = ThingDeviceActiveBuilder()
.setActiveModel(ThingDeviceActiveModeEnum.QC)
.setContext(context)
.setSsid(ssid)
.setPassword(pwd)
.setToken(token)
.setTimeOut(timeout)
.setListener(object : IThingDeviceActiveListener {
override fun onFind(devId: String) {
}
override fun onBind(devId: String) {
}
override fun onActiveSuccess(deviceBean: DeviceBean) {
}
override fun onActiveError(errorBean: ThingDeviceActiveErrorBean) {
}
override fun onActiveLimited(limitBean: ThingDeviceActiveLimitBean) {
}
})
val activeManager = ThingActivatorCoreKit.getActiveManager().newThingActiveManager()
activeManager.startActive(builder)
Parameter description
Parameters | Description |
---|---|
context | The context. |
ssid | The name of the target Wi-Fi network. |
pwd | The password of the target Wi-Fi network. |
timeout | The timeout value, in seconds. |
token | The information about the token. |
activeModel | The pairing capability enum. |
listener | The callback for the result of pairing. |
activeManager.stopActive()
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback