Confirm successful WiFi provisioning via SoftAP
benrudhart opened this issue · 5 comments
Description
When using espDevice.provision(ssid: ssid, passPhrase: passphrase) { status in }
as described in the Readme there is no callback I could find that would report a success.
Once my device uses the provided credentials it kills the SoftAP (I'm provisioning via WiFi). Hence I don't get any feedback.
Is this expected or do I miss something?
To Reproduce
Steps to reproduce the behavior:
- create an ESPDevice and provision wifi credentials
- wait until success is reported (which should be done via pulling of wifi status, which is the last step in
espDevice.provision
Frequency
Every time
Expected behavior
There is a way to differentiate between success/ failure when doing WiFi provisioning
ESP Device Information:
- ESP-IDF version: [e.g. 4.0]
- Example referenced: [e.g. wifi_prov_mgr]
- Board type: [e.g. ESP-32]
iOS information:
- Device type: [e.g. iPhone/iPad]
- iPhone
- Device model: [e.g. iPhone 7]
- iPhone 14
- iOS version: [e.g. iOS8.1]
- 16
- App Version: [e.g. v.2.0.8]
- used the SDK
Provisioning information:
- ESPProvision iOS SDK version: [e.g. 2.0.8] (if applicable)
- 2.1.0
- Device type: [e.g. SoftAP/ BLE]
- SoftAP
- Security: [e.g. Secure/Unsecure]
- Sec1
Hi @benrudhart, provision API sends information on success, failure, and when WI-FI configuration is applied successfully on the device.
For more detailed usage of this API, kindly refer to the ESPProvisionSample app within the repository:
.Thanks, I tried this with the provided ESPProvisionSample
.
Results: The app shows a failure in the Step "Confirming Wi-Fi connection." : "Unable to fetch Wi-Fi state. See screenshot:
I debugged this and was able to observe the following:
The error is caught in line 85 in the file you provided. The App also logs this error to console:
finished with error [-1009] Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline."
To me it appears that the App is no longer connected to the SoftAP (since the device now connected to the WiFi which I asked it to provision). I guess this is kind of expected behavior of the device, though the App shows an error.
Therefore I get back to my initial question: Is it possible to confirm (via the SDK) that the device properly connected to the provided WiFi?
Hi @benrudhart this error is coming from the device. The device is giving an error when we are trying to fetch the status after applying the Wi-Fi configuration. Can you please send us the device detail logs using the debug mode?
Additionally, you can try placing the device near the router while provisioning or try with different Wi-Fi networks to ensure that it is not related to a poor network signal.
@benrudhart ESP chips have 2 interfaces, station and softAP, but a single antenna. So, when the device receives the Wi-Fi network credentials, and tries connecting to the target AP using the station interface, the softAP channel also switches to the target APs channel. While this channel switches, some phones have a tendency to immediately disconnect and reconnect to some other saved network. Since the connection has dropped, the phone cannot query the status and so the failure is seen. In our experience, this happens mostly with Android phones though, not with iOS. Moreover, this issue occurs only with SoftAP provisioning, not BLE.
I am not sure if this is indeed the issue here, but could be possible.
For me it happened on iOS, and yes - I was using SoftAP. Unfortunately I'm unable to provide device detail logs