Last Updated on : 2024-05-28 06:12:20download
Sub-device pairing can be initiated only when a gateway is online in the cloud, and the sub-device stays in pairing mode. This topic describes how to pair a sub-device, using the Zigbee sub-device as an example.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
mode |
ActivatorMode |
Yes | The pairing mode. |
Example
self.pair = ActivatorService.shared.activator(.zigbeeSubDevice)
IActivatorListener
to listen for pairing resultParameters
Parameter | Type | Required | Description |
---|---|---|---|
deviceModel |
IActivatedDevice? |
Yes | If the operation is successful, it indicates the information about the activated device. Otherwise, it is nil . |
params |
ActivatorParams? |
Yes | The parameters of actions. |
Callbacks
Function name | Parameter | Description |
---|---|---|
onSuccess |
deviceModel: IActivatedDevice? , params: ActivatorParams? |
The success callback, returning the information about the activated device. |
onError |
error: Error, params: ActivatorParams? |
The failure callback, returning an error message. |
Example
private func start() {
pair.listener = self
}
extension TableViewController: IActivatorListener {
func onSuccess(deviceModel: IActivatedDevice?, params: ActivatorParams?) {
SVProgressHUD.dismiss()
self.navigationController?.popToRootViewController(animated: true)
}
func onError(error: Error, params: ActivatorParams?) {
SVProgressHUD.dismiss()
SVProgressHUD.showInfo(withStatus: error.localizedDescription)
}
}
This method starts device pairing.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
params |
ActivatorParams |
Yes | The parameters of the pairing action. See the example. |
gwId |
String |
Yes | The ID of the gateway, which is the device.deviceId . |
localKey |
String |
Yes | The key for local communication. |
pv |
Double |
Yes | The protocol version, which is the device.pv of the gateway. |
Example
// Create ZigbeeSubDeviceActivatorParams instance.
let params = ZigbeeSubDeviceActivatorParams(gwId: "my_gwId", localKey: "my_local_key", pv: "my_pv")
// Start pairing. pair is generated during initialization.
// self.pair = ActivatorService.shared.activator(.zigbeeSubDevice)
pair.startPair(params)
This method stops device pairing.
Example
// Stop pairing. pair is generated during initialization.
// self.pair = ActivatorService.shared.activator(.zigbeeSubDevice)
pair.stopPair()
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback