Last Updated on : 2024-09-14 06:40:52download
This topic describes how to activate Wi-Fi and Bluetooth combo devices in the cloud.
IDevice().meta?["wifiEnable"]
to get the Wi-Fi connection status. A value of true
indicates that the cloud-based activation is successful.Smart Industry App SDK does not provide the logic for precheck. You can implement it on your own.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
mode | ActivatorMode | Yes | The pairing mode. |
Sample code
self.pair = ActivatorService.shared.activator(.BLEWIFICloud)
Get the parameters from the result of the scanning listener.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
devId | String | Yes | The ID of the device. |
ssid | String | Yes | The SSID of the Wi-Fi network. |
pwd | String | Yes | The password of the Wi-Fi network. |
timeout | Long | No | The timeout for device activation in the cloud, in milliseconds. Default value: 100. |
let params = BLEWIFICloudActivatorParams(devId: deviceId, ssid: "", password: "")
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
deviceModel | IActivatedDevice? |
Yes | The information of the activated device for success and nil for failure. |
params | ActivatorParams? |
Yes | The parameter information of the operation. |
Callback functions
Function | Parameter | Description |
---|---|---|
onSuccess | deviceModel: IActivatedDevice?, params: ActivatorParams? |
The callback function used when the operation succeeds. It returns the information of the activated device. |
onError | error: Error, params: ActivatorParams? |
The callback function used when the operation fails. It returns an error message. |
Sample code
private func start() {
pair.listener = self
}
extension TableViewController: IActivatorListener {
func onSuccess(deviceModel: IActivatedDevice?, params: ActivatorParams?) {
SVProgressHUD.dismiss()
}
func onError(error: Error, params: ActivatorParams?) {
SVProgressHUD.dismiss()
SVProgressHUD.showInfo(withStatus: error.localizedDescription)
}
}
This method starts the device pairing.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
params | ActivatorParams | Yes | The information of the pairing parameters. For more information, see the following sample code. |
deviceInfo | ThingBLEAdvModel | Yes | The information of the device. |
assetId | String | Yes | The ID of the asset. |
pairToken | String | Yes | The token for pairing. |
ssid | String | Yes | The SSID of the Wi-Fi network. |
password | String | Yes | The password of the Wi-Fi network. |
onlyConnectBle | Boolean | No | Specifies whether the device can only be activated through a Bluetooth connection. Default value: false . |
Sample code
// Start device pairing. The pair is generated during initialization.
// self.pair = ActivatorService.shared.activator(.BLEWIFI)
self.pair.startPair(BLEWIFIActivatorParams(deviceInfo: devInfo, assetId: assetID, pairToken: self.pairingToken, ssid: self.ssid, password: self.password, onlyConnectBle: true))
This method starts the device activation in the cloud.
Sample code
let iDevice = IndustryDevice(deviceId: device?.deviceId ?? "")
iDevice.connectBLE {
// let params = BLEWIFICloudActivatorParams(devId: deviceId, ssid: "", password: "")
self.pair.startPair(params)
} failure: {
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback