espressif / esp-idf-provisioning-ios

Apache License 2.0
130 stars 62 forks source link

Confirm successful WiFi provisioning via SoftAP #67

Open benrudhart opened 1 year ago

benrudhart commented 1 year ago

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:

Frequency Every time

Expected behavior There is a way to differentiate between success/ failure when doing WiFi provisioning

ESP Device Information:

iOS information:

Provisioning information:

vikas-chandra-mnnit commented 1 year ago

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:https://github.com/espressif/esp-idf-provisioning-ios/blob/4668cdacfaf924fd3292ee2f11c2216c92864c12/Example/ESPProvisionSample/ESPProvisionSample/Provision/StatusViewController.swift#L69.

benrudhart commented 1 year ago

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: IMG_5A063FFDA8B9-1

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?

vikas-chandra-mnnit commented 1 year ago

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.

shahpiyushv commented 1 year ago

@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.

benrudhart commented 1 year ago

For me it happened on iOS, and yes - I was using SoftAP. Unfortunately I'm unable to provide device detail logs