espressif / esp-idf-provisioning-android

Android Provisioning application for ESP-IDF Unified provisioning
Apache License 2.0
202 stars 133 forks source link

Incorrectly reports provisioning failure #95

Open szekelyisz opened 8 months ago

szekelyisz commented 8 months ago

Trying to provision ESP8266 through SoftAP. Even though provisioning succeeds according to the device, this library still calls the onProvisioningFailed and provisioningFailedFromDevice callbacks so the application is unable to tell whether the provisioning was successful or not.

I understand that this is because the device is already connected to the WiFi in STA mode so it's unable to send the result of the provisioning operation back to the application over SoftAP unless they share the same channel. Still, this library should not call the callbacks that indicate definite failure.

Stack trace ``` I/MainActivity(17643): provision: sending credentials I/MainActivity(17643): provision: credentials sent I/MainActivity(17643): wifiConfigSent I/MainActivity(17643): wifiConfigApplied E/ESP:ESPDevice(17643): Lost Network Connection - 3 E/Espressif::SoftAPTransport(17643): socket failed: ENONET (Machine is not on the network) W/System.err(17643): java.net.SocketException: socket failed: ENONET (Machine is not on the network) W/System.err(17643): at java.net.Socket.createImpl(Socket.java:492) W/System.err(17643): at java.net.Socket.getImpl(Socket.java:552) W/System.err(17643): at java.net.Socket.setSoTimeout(Socket.java:1180) W/System.err(17643): at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:139) W/System.err(17643): at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:112) W/System.err(17643): at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:184) W/System.err(17643): at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126) W/System.err(17643): at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95) W/System.err(17643): at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281) W/System.err(17643): at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224) W/System.err(17643): at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:461) W/System.err(17643): at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:127) W/System.err(17643): at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:258) W/System.err(17643): at com.espressif.provisioning.transport.SoftAPTransport.sendPostRequest(SoftAPTransport.java:85) W/System.err(17643): at com.espressif.provisioning.transport.SoftAPTransport.access$000(SoftAPTransport.java:43) W/System.err(17643): at com.espressif.provisioning.transport.SoftAPTransport$1.run(SoftAPTransport.java:143) W/System.err(17643): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458) W/System.err(17643): at java.util.concurrent.FutureTask.run(FutureTask.java:266) W/System.err(17643): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) W/System.err(17643): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) W/System.err(17643): at java.lang.Thread.run(Thread.java:764) W/System.err(17643): java.lang.RuntimeException: Error ! Connection Lost W/System.err(17643): at com.espressif.provisioning.transport.SoftAPTransport.sendPostRequest(SoftAPTransport.java:120) W/System.err(17643): at com.espressif.provisioning.transport.SoftAPTransport.access$000(SoftAPTransport.java:43) W/System.err(17643): at com.espressif.provisioning.transport.SoftAPTransport$1.run(SoftAPTransport.java:143) W/System.err(17643): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458) W/System.err(17643): at java.util.concurrent.FutureTask.run(FutureTask.java:266) W/System.err(17643): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) W/System.err(17643): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) W/System.err(17643): at java.lang.Thread.run(Thread.java:764) D/ESP:ESPDevice(17643): disableOnlyWifiNetwork() E/MainActivity(17643): onProvisioningFailed: E/MainActivity(17643): java.lang.RuntimeException: Provisioning Failed E/MainActivity(17643): at com.espressif.provisioning.ESPDevice$12.onFailure(ESPDevice.java:929) E/MainActivity(17643): at com.espressif.provisioning.Session$2.onFailure(Session.java:141) E/MainActivity(17643): at com.espressif.provisioning.transport.SoftAPTransport.sendPostRequest(SoftAPTransport.java:120) E/MainActivity(17643): at com.espressif.provisioning.transport.SoftAPTransport.access$000(SoftAPTransport.java:43) E/MainActivity(17643): at com.espressif.provisioning.transport.SoftAPTransport$1.run(SoftAPTransport.java:143) E/MainActivity(17643): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458) E/MainActivity(17643): at java.util.concurrent.FutureTask.run(FutureTask.java:266) E/MainActivity(17643): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) E/MainActivity(17643): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) E/MainActivity(17643): at java.lang.Thread.run(Thread.java:764) E/MainActivity(17643): provisioningFailedFromDevice D/ESP:ESPDevice(17643): disableOnlyWifiNetwork() E/ESP:ESPDevice(17643): Connectivity Manager is already unregistered ```
hivislav commented 1 week ago

@szekelyisz Hello! Were you able to find any solution?)