AP 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.
Connect the phone to the device’s AP hotspot, then provision the discovered LAN device.
import com.gizwits.smart.sdk.lan.lanCapability
import com.gizwits.smart.sdk.core.capacity.CapacityStatus
// Run in a coroutine; use true when the AI module binds itself in the cloud
val bindWithUid = true
val capability = device.lanCapability
if (capability.getStatus() != CapacityStatus.OFFLINE) {
val result = capability.provideWiFiCredentials(
ssid = ssid,
password = password,
timeout = 60L,
processHandler = { event -> println(event) },
bindWithUid = bindWithUid
)
result.onSuccess {
// Provisioning succeeded; the result is Unit. Obtain devices from device lists.
}.onFailure { error -> println(error) }
}Stop Provisioning
val stopResult = device.lanCapability.stopProvideWiFiCredentials()