BLE Provisioning
timeout is in seconds: 60 means 60 seconds. bindWithUid is nullable but has no default argument, so it must be supplied explicitly.
AI module requirement: when an AI module establishes its own binding relationship with the cloud, SDK provisioning must set bindWithUid = true. Sign in first, or supply a valid uid and token. This mode uses the current user’s bound-device list to confirm provisioning. Pass false for ordinary provisioning. The flag does not replace sign-in or mean that the app calls the device’s bind() method.
Scan and obtain the device before provisioning. For modules advertising 5 GHz provisioning support, the SDK selects the appropriate protocol automatically.
The return type is GizResult<GizBaseProfile?, GizActivatorException?>. Read module information from the capability’s deviceProfile property. netStatus is an enum.
import GizwitsiOSSDK
// Run in a Task or async function; use true when the AI module binds itself in the cloud
let bindWithUid = true
let capability = device.bleCapability
if let profile = capability.deviceProfile as? GizBleProfile,
profile.configured == false, capability.isOnline {
let result = await capability.provideWiFiCredentials(
ssid: ssid,
password: password,
timeout: 60,
processHandler: { event in print(event) },
bindWithUid: bindWithUid
)
if let error = result.error ?? nil, error == .GIZ_SDK_DEVICE_CONFIG_TIMEOUT {
print("Timeout")
}
if result.success, let configuredDevice = result.data ?? nil {
print(configuredDevice.mac)
}
}Stop Provisioning
let stopResult = await device.bleCapability.stopProvideWiFiCredentials()