espressif / esp-rainmaker-android

ESP RainMaker Android app sources
https://rainmaker.espressif.com/
Apache License 2.0
95 stars 55 forks source link

Mobile phone compatibility for RainMaker Android App using ESP32S2 (MEGH-3184) #17

Open eos1d3 opened 2 years ago

eos1d3 commented 2 years ago

I tried the LED Light example using IDF Release 4.3. ESP32 boards work without issue. But ESP32S2 just cannot be added using Poco X3 NFC mobile phone.

Another ESP-C3 with factory flashed LED Light example works with this mobile phone.

After scanning the QR Code, a small window showing:

Connect to device

ESP Rainmaker app wants to use a temporary Wi-Fi network to connect to your device
PROV-xxxxxx

After clicking Connect, a single line of message "Connection successful" is shown, but it jumps to another window showing:

Device connection failed.
Do you want to connect device manually

After clicking Yes, the app open a full screen for asking Connect to Device PROV_xxxxxx. Clicking Connect and get it connected, but RainMaker is still showing Connecting and finally change the button to Connect again.

From my mobile, I find it is really connected to PROV-xxxxxx. But it just can't be added even I tried other ESP32S2 boards, including SOLO and Saola.

The strange thing is another LG mobile phone works with these ESP32 devices. Rainmaker app just does not show the above windows, but showing Select Wi-Fi Network directly with a message: To complete setup of your device, PROV-xxxxxx, please provide your Home Network credentials.

The RainMaker app version is 2.4.1 - 21c2060 is used for Poco X3 NFC from PlayStore. APK direct link, version 2.0.2 97f5372 from Espressif is also used with exactly the same problem.

shahpiyushv commented 2 years ago

@eos1d3 the most important difference between esp32c3 and esp32s2 that esp32c3 uses BLE provisioning whereas esp32s2 uses SoftAP. We indeed have seen that some Android variants do not work correctly with SoftAP, especially because this interface does not have Internet. Can you check your phone's Wi-Fi settings once to see if there is some "intelligent" switching enabled to ensure that the phone is always connected to the Internet?

eos1d3 commented 2 years ago

@shahpiyushv I have tried many times enabling "WiFI Assistant -Stay connected". This says to use mobile data when Wi-Fi network cannot connect to the internet. But no matter how many times I tried, the problem is the same.

But from WiFi setting, I can see my phone WiFi is connected to the soft SoftAP.

shahpiyushv commented 2 years ago

@eos1d3 , as a matter of fact, if the phone tries to use 4G if no Internet is available on Wi-Fi , things may fail, since the packets meant for the ESP32S2 would also get re-directed to the 4G interface. We have actually added code to ensure that the packets are always sent on Wi-Fi interface, but I am not sure if this behaviour changes as per the Android variant. I have moved this issue since it is related to phone app rather than the firmware. I will also ask our app developers to help debug.

eos1d3 commented 2 years ago

I have tried to disable mobile data too. But the problem is the same.

PS: One thing is strange. I can see a line of message appeared "Connection successful" in around 1 second and then another screen asking to connect the SoftAP.

eos1d3 commented 2 years ago

Hi, I just tried my ESP32S2 with the same mobile phone Poco X3 NFC to test Station Example using IDF R4.4. https://github.com/espressif/esp-idf/tree/master/examples/wifi/getting_started/station

I find there is AP band in Portable Hotspot setting in my phone. Two options are available for 2.4G and 5G bands. If I use 2.4G the example can connect my phone. But after scanning QR code from ESP32S2, I can see its SSID and my phone can connect to it. It is just the Rainmaker app can't connect the device.

This is log output:

I (499) wifi:mode : sta (7c:df:a1:0f:70:9e)
I (499) wifi:enable tsf
I (499) wifi station: wifi_init_sta finished.
I (1719) wifi:new:<11,0>, old:<1,0>, ap:<255,255>, sta:<11,0>, prof:1
I (3229) wifi:state: init -> auth (b0)
I (3239) wifi:state: auth -> assoc (0)
I (3259) wifi:state: assoc -> run (10)
I (3279) wifi:connected with myssid, aid = 1, channel 11, BW20, bssid = 02:94:90:a0:82:f2
I (3279) wifi:security: WPA2-PSK, phy: bgn, rssi: -43
I (3289) wifi:pm start, type: 1

I (3319) wifi:AP's beacon interval = 102400 us, DTIM period = 2
I (4219) esp_netif_handlers: sta ip: 192.168.141.25, mask: 255.255.255.0, gw: 192.168.141.74
I (4219) wifi station: got ip:192.168.141.25
I (4219) wifi station: connected to ap SSID:myssid password:mypassword
I (24739) wifi:state: run -> init (1a0)
I (24739) wifi:pm stop, total sleep time: 19996268 us / 21446206 us

I (24739) wifi:new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1