WiFi issue with Google Pixel / Android 9, 10

atlascoder
Posts: 51
Joined: Wed Aug 30, 2017 12:36 pm

WiFi issue with Google Pixel / Android 9, 10

Postby atlascoder » Sun Oct 20, 2019 11:04 pm

I have a trouble with WiFi operations when using specific device Google Pixel on Android 10, and previously Android 9. With other devices, like iPhone 7, 8, iPad (iOS 12,13), Samsung J (Android 7), MacOS - everything works fine.

The problem appears in my scenario of device Setup (aka Provisioning):

1. ESP runs SoftAP mode
2. A device connects to ESP as a WiFi station
3. The device performs communications via TCP protocol as a client, ESP has running TCP server
4. Once the device sends WiFi credentials, ESP starts to connect to another AP as a station
5. After ESP started to connect to the AP - communication with the device became broken: TCP/IP stack on ESP does not receive any packet from WiFi driver.

Below are some results of my survey that make sense to say that packets do not come from WiFi driver.

I turned on debug logs in LWIP for TCPIP_IN and I can see that lwip receives buffers before ESP started to connect to an AP, because I can see a lot of prints of LWIP logs before this event, and I see no prints after ESP started to connect to AP and while the device (client) is trying to establish a TCP session. Using Wireshark I can see traffic from device to ESP: device is trying to initiate a TCP session by sending TCP [SYN] and I see a lot of TCP retransmissions because ESP does not reply with [SYN, ACK]. Also, I see successful streams on Wireshark before the ESP connection event.

I tried to find differences between [SYN] packets from iPhone and Pixel. There are only few differences:
1) Window scale:
Pixel: WS=256
iPhone: WS=64
2) TCP options:
Pixel, 20 bytes: MSS=1460, SACK Perm, Timestamps, NOP, WS=256
iPhone, 24 bytes: MSS=1460, NOP, WS=64, NOP, NOP, Timestamps, SACK Perm, EOL

I suspect, that something happens with STA part of ESP WiFi driver after ESP started to connect to AP. Also, if I do deauth of connected STA, and reconnect this STA again - it can communicate normally again. Unfortunately, after deauthed, Pixel does not connect automatically to ESP and this approach can't be a workaround for me.

ESP-IDF 3.3.

I've tried to stop/up AP interface, to recreate the TCP server socket, to use Lwip RAW API - that do not help. I have solid view that TCP packets just stopped to go to lwip, and it loos reasonable that all my actions did not help.

I am loosing ideas.. WiFi driver is binary and I can't survey deeper.

Any ideas?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: WiFi issue with Google Pixel / Android 9, 10

Postby WiFive » Mon Oct 21, 2019 3:14 am

Once the device sends WiFi credentials, ESP starts to connect to another AP as a station
Is this in AP+STA mode?
After ESP started to connect to the AP - communication with the device became broken: TCP/IP stack on ESP does not receive any packet from WiFi driver
Is this because esp32 changes channel and pixel does not automatically switch channel?

atlascoder
Posts: 51
Joined: Wed Aug 30, 2017 12:36 pm

Re: WiFi issue with Google Pixel / Android 9, 10

Postby atlascoder » Mon Oct 21, 2019 9:46 am

Hello WiFive!

Thanks for the quick reply.

My implementation is like the following (pseudocode):

1. Initializing WiFi in APSTA mode
2. Running AP
3. Running HTTP server (custom one, using lwip socket)
4. Once credentials received, - call esp_wifi_set_config(WIFI_IF_STA, config) and esp_wifi_connect
....
x. If connection was successful - I call esp_wifi_set_storage(FLASH), esp_wifi_set_config(WIFI_IF_STA, config) and esp_wifi_set_mode(STA).

Please, keep in mind, that the solution works with most of my devices, and the issues exist with Google Pixel.

Regarding channels - I did not check if after esp_wifi_connect the ESP has changed the channel in AP module. I will check.
But at the moment I have doubts that this makes sense, because: any of phones do not disconnect from WiFi connection whether it was iPhone, Pixel or other.

Also, I had experience, in another project, with deauthing of WiFi devices, and I always observed almost immediate reconnection of a disconnected device. Here I see in monitor that STA was disconnected (event AP_STA_DISCONNECTED) but the prone is still showing WiFi connected state (wifi indicator) for a quite long time. So, I suspect that in fact, ESP does not send 802.11 Deauth mgmt packets and just does remove STA association from internal registry. Though, I did not check this with Wireshark yet. I will.

I can send pcap files to you.
Last edited by atlascoder on Tue Oct 22, 2019 5:36 pm, edited 1 time in total.

atlascoder
Posts: 51
Joined: Wed Aug 30, 2017 12:36 pm

Re: WiFi issue with Google Pixel / Android 9, 10

Postby atlascoder » Mon Oct 21, 2019 9:24 pm

OK, WiFive, I have some results regarding your question #2.

Though Wireshark does not report channel correctly - it always shows channel 1, - I can see traffic anyway. So, I can't say that ESP AP changes channel on connecting as STA to another AP. But I see traffic from ESP client (a phone) and this means that at least the phone WiFi client has no information about WiFi channel shutdown and deem connection as working. Also, I see traffic from ESP STA to another AP and this means that if ESP did change channel on connecting as STA and this channel would be the same for ESP AP and if everything would keep working correctly - I had to see at least Beacons from ESP AP and other traffic as well.

I don't see 802.11 DEAUTH packets from ESP when call esp_wifi_deauth(aid), but I see such packets from the phone after some time of unsuccessful communications. Also, after connection of ESP STA to another AP - I stopped to see Beacons from ESP AP.

atlascoder
Posts: 51
Joined: Wed Aug 30, 2017 12:36 pm

Re: WiFi issue with Google Pixel / Android 9, 10

Postby atlascoder » Mon Oct 21, 2019 9:48 pm

I would like to understand if I can rely on my scenario and try to find solution myself or with your help in some reasonable time.

I have some conclusions that lead me to understand that I can't rely on my scenario, because:

1. ESP WiFI driver does not send real 802.11 DEAUTH packet when esp_wifi_deauth(sta_aid) is called - it just removes sta_aid from internal WiFi structures, what leads to ignorance of traffic from/to sta_aid. So, I can't use deauth for forcing connected sta reconnection in order to get side effect of connection structures re-creation. The re-creation would help, because I found that after sta reconnection - communications works well again.

2. Something is going wrong with packets from Google Pixel after STA iface connected. And this happens inside WiFi driver because no pbufs are being transferred to lwip. Since lwip code is open and WiFi driver is a binary lib - I can't locate and fix it myself.

So, if my suppositions are true, the I understand that I hardly can do here something and have to rely on your help.

Do you confirm that points 1 and 2 are true?

atlascoder
Posts: 51
Joined: Wed Aug 30, 2017 12:36 pm

Re: WiFi issue with Google Pixel / Android 9, 10

Postby atlascoder » Fri Oct 25, 2019 8:44 am

Hello, WiFive!

Any suggestions regarding this?

Thank you.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: WiFi issue with Google Pixel / Android 9, 10

Postby WiFive » Fri Oct 25, 2019 9:51 am

Sorry, I don't know. There are lots of problems reported about WiFi on pixel, so I am not sure this is on esp32 side.

You said
If connection was successful - I call esp_wifi_set_storage(FLASH), esp_wifi_set_config(WIFI_IF_STA, config) and esp_wifi_set_mode(STA).
Wouldn't that disable AP?

atlascoder
Posts: 51
Joined: Wed Aug 30, 2017 12:36 pm

Re: WiFi issue with Google Pixel / Android 9, 10

Postby atlascoder » Fri Oct 25, 2019 11:19 am

WiFive, thank you for the reply!

I am surprised about this:
There are lots of problems reported about WiFi on pixel
Yes, you are right that this turns AP off:
If connection was successful - I call esp_wifi_set_storage(FLASH), esp_wifi_set_config(WIFI_IF_STA, config) and esp_wifi_set_mode(STA).
- but this is what I need in fact.

Sorry, but I wrote a bit incorrect scenario of my provisioning, here is the correct one:

1. Initializing WiFi in APSTA mode
2. Running AP
3. Running HTTP server (custom one, using lwip socket)
4. Once credentials received, - call esp_wifi_set_config(WIFI_IF_STA, config) and esp_wifi_connect
5. While connection, the ESP HTTP server is up and replies on requests with custom reply that ESP is connecting
6. When ESP got connection to another AP - the ESP HTTP server is also up and replies that ESP is Connected
7. ESP client (phone) receives replies, and when reply is Connected - it sends some user data to ESP and sends a request that setup is finished
8. If ESP receives from client the Finished message - ESP executes esp_wifi_set_storage(FLASH), esp_wifi_set_config(WIFI_IF_STA, config) and esp_wifi_set_mode(STA).

The pixel issue appears on step 5: phone is still sending requests, ESP AP is up, but packets do not appear in LWIP stack.

With other phones it works fine.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: WiFi issue with Google Pixel / Android 9, 10

Postby WiFive » Fri Oct 25, 2019 12:01 pm

Ok. If you attach sniffer captures of pixel vs working phone maybe someone can help.

atlascoder
Posts: 51
Joined: Wed Aug 30, 2017 12:36 pm

Re: WiFi issue with Google Pixel / Android 9, 10

Postby atlascoder » Sat Oct 26, 2019 10:04 am

OK, before sending pcap's I went through the traffic again and found that there are no Data packets after ESP STA started and I concluded that this is perhaps due to channel change. I used another WiFi monitor that shows right channels and I confirm that ESP AP changes channel when ESP STA is starting to connect.

Also, esp_wifi_deauth(aid) works fine with Pixel before channel change. Unfortunately, Pixel does not reconnect to this AP again and choses another network.

Also, I can find several 802.11 Beacon packets from ESP AP which contain Channel Switch Announcement, but it looks like Pixel does not follow channel change by these beacons for some reason.

I attach pcaps, My ESP AP SSID is Leviosa-594434.
Attachments
Archive.zip
pcaps
(6.37 MiB) Downloaded 568 times

Who is online

Users browsing this forum: Bing [Bot] and 273 guests