particle-iot / spark-setup-android

Former home of the Particle Device Setup library for Android
Apache License 2.0
23 stars 30 forks source link

Unable to configure WiFi credentials in P1 devices #64

Closed antoniovazquezblanco closed 6 years ago

antoniovazquezblanco commented 6 years ago

I have found dificulties configuring WiFi credentials in multiple P1 devices. After ensuring the device is flashing blue, I open the app and click on the device I want to configure but a dialog with an error message appears advicing to reset my device.

After loading the app in android studio we have found that an exception is raised in: https://github.com/particle-iot/spark-setup-android/blob/6b3ca1696cee46d554338ecccec5e09b6403901d/devicesetup/src/main/java/io/particle/android/sdk/devicesetup/ui/DiscoverProcessWorker.java#L54

Due to a failure in the following line when the phone attempts to parse the response of a device id request. https://github.com/particle-iot/spark-setup-android/blob/6b3ca1696cee46d554338ecccec5e09b6403901d/devicesetup/src/main/java/io/particle/android/sdk/devicesetup/commands/CommandClient.java#L111

After performing some analisys with wireshark, it seems that the soft AP is responding as expected but android was unable to read the response due to a socket exception "Software caused connection abort".

I have been able to configure devices with my One Plus 3 with Android 8.0.0. I cannot configure devices with a One Plus 5 and a Nexus 6P, both running Android 8.1.0.

Thank you

Ping: @tresmele @jboalml

jensck commented 6 years ago

Do you have this same issue with a Photon?

jensck commented 6 years ago

Also, what version of the device firmware are you using?

antoniovazquezblanco commented 6 years ago

Do you have this same issue with a Photon?

I have not tested this with a Photon device. I will have to look if I have one device available and will get back with more information.

Also, what version of the device firmware are you using?

Currently v0.6.0. We are working on updating our application to use v0.8 but will not be ready for a while. Anyways, seems related to the phone App rather than the device fw given that following the Wireshark captures the response was correctly sent and the socket buffer had the response although it was not able to pop it due to the socket being closed.

antoniovazquezblanco commented 6 years ago

More info. We are able to configure WiFi credentials with a One Plus X with Android 6.0.

It seems we can perform tests with a Photon device. I will get back when we have the results.

jensck commented 6 years ago

I've got a Pixel 2 XL that's running 8.1.0, which should be the same build as your 6P. I'll try to repo this with a Photon today.

antoniovazquezblanco commented 6 years ago

We have tested a Photon device with the Nexus 6P and we were able to configure it but from what I've seen it seems more related to the phone side. How should we proceed to triage this?

Thanks

jensck commented 6 years ago

Given all that you've described, I think the next thing to try is to adjust the timeout value here: https://github.com/particle-iot/spark-setup-android/blob/6b3ca1696cee46d554338ecccec5e09b6403901d/devicesetup/src/main/java/io/particle/android/sdk/devicesetup/commands/CommandClient.java#L23

Are you comfortable making your own build of the device setup lib to try this?

Tresmele commented 6 years ago

We have increased the timeout value to 30 seconds and the phone was able to configure the P1 correctly. By increasing the timeout the phone keeps retrying to connect to the P1 until eventually it succeeds, but we have seen the response in wireshark and in android studio, so what is exactly the problem?. Can we consider this solution robust?

jensck commented 6 years ago

To clarify: when you say you saw the response in Android Studio, do you mean that you were able to confirm that the bytes were received on phone's socket connection to the P1, but they weren't always being read by CommandClient?

Tresmele commented 6 years ago

Yes, when the app reaches the line: https://github.com/particle-iot/spark-setup-android/blob/6b3ca1696cee46d554338ecccec5e09b6403901d/devicesetup/src/main/java/io/particle/android/sdk/devicesetup/commands/CommandClient.java#L111 The debugger shows the device_id correctly inside the buffer, but once that line is executed the exception "Software caused connection abort" is triggered.

jensck commented 6 years ago

Thanks for the detailed feedback! We'll find some time to look into this further.

jensck commented 6 years ago

Sorry for the delay on this. We tested this using a Nexus 6P and a Photon RedBoard, which is P1-based.

Quoting our tester: "tested on nexus 6p. Results -> Setup on both Tinker & Setup library/example worked fine. Nexus 6P was on 8.1 while redboard was on 0.6.0."

Is it possible that this problem is something device or environment specific?

antoniovazquezblanco commented 6 years ago

The issue was partially solved by increasing the timeout in the configuration app. We can keep things working as is and we will soon be migrating to 0.8.x fw.

For the time being we will consider the issue solved and if we find any difficulties after the update we will get back into this.

Thank you!