Closed emc-vishaal closed 1 year ago
Hi @emc-vishaal, the log shows that the ESP32C6 does not receive a TWT response from AP. Can you help to check whether the AP supports individual TWT?
hi @xuxiao111 I don't have the exact model number on hand but I have an enterprise grade TP-Link WIFI 6 access point...I'd assume these ones have TWT capability (is there a difference between TWT and individual TWT and are only a select number of router models equipped with the individual version?)
Hi @emc-vishaal , TWT includes individual TWT and broadcast TWT, and now we only support individual TWT. Also, you can use Wireshark to capture the beacon frame sent by AP and check the HE capabilities to confirm the AP supports individual TWT.
Hi @xuxiao111 I've installed Wireshark but am not able to see anything similar to your window...did you have to create filters or monitor a specific IP address? I see nothing when I set a capture filter to the IP address of the ESP32
Hi @emc-vishaal, you can follow this wiki to capture wireless frames. https://wiki.wireshark.org/CaptureSetup/WLAN. Or can you show the detailed info about the TP-Link access point that you used?
Hi @xuxiao111
It appears our AP does support ITWT according to the beacon frame read in wireshark:
Hi @emc-vishaal, can you help to capture the itwt setup response frame sent by AP?
Hi @xuxiao111 ~~Looks like neither of these messages exist for me. In the code, the function call to esp_wifi_sta_itwt_setup returns ESP_OK after getting an IP so I'm assuming the ESP32 is sending the TWT Setup message to the AP but I don't see anything with the name "espressif" on the wireshark interface...no entries with "espressif" or "esp" in either source or destination columns~~
It takes a few attempts of going through the "send TWT setup request" function call but I finally found something that looks like a malformed setup coming from the ESP32:
Getting that malformed frame is actually kind of hard to replicate. I can run the setup function over and over again and I either get nothing at all on Wireshark, or the malformed frame once every so often. I let it run calling the "setup request" function every 3 seconds or so, and I only see the malformed frame go out twice in 5 minutes.
Hi @emc-vishaal, can you find the twt setup response frame from AP? If you can't find it, maybe this is an AP firmware issue, you can update the AP firmware to check whether it's ok in the new firmware version or change to another AP which supports ITWT. (ASUS-AX56U,ASUS-AX86U,ASUS-88U, Linksys-MX4200, Linksysy-MX5300)
Hi @xuxiao111 , it appears there is no response frame from the AP. Filtering by frames going to and from the MAC address of the ESP32, the only packets seen are some that are being sent by ESP32 and then at times ACK frames that don't have a source address.
If the setup packet going from the ESP32 to the AP is showing up as malformed, is there a way to fix this in the ESP32? Would you be able to show me a screenshot of what the expected setup frame from ESP32 to AP looks like?
Wireshark version:
Thanks @xuxiao111 I was on a different version of wireshark, I get something similar to you now. I see a difference in our request packet (from ESP32). What is the exponent you are using in your configuration? I am using exponent = 10 and mantissa=512. Any idea why my wakeup time number is so high? doesn't match up to 512*2^10
Screenshot of ESP32 to AP request frame
Also have confirmed my AP [TP-LINK OMADA Series EAP610] is updated to latest firmware and according to our previous wireshark screenshots should be able to support ITWT
Hi @emc-vishaal, the default wakeup time is about 255256 = 65280 (us), and the wake interval is about 512 2^10 = 524288 (us). I think these two times are OK.
Hi @xuxiao111
Right, so the 1784062566400 number next to Target Wake Time: in the frame makes me think something is going wrong with the conversion of the mantissa and exponent from the configuration to whatever is coming out on the frameover wifi...is there anything else you can think of that's wrong with the TWT setup request? I can't access any code past the call to esp_wifi_sta_itwt_setup
Hi @emc-vishaal, after calling the esp_wifi_sta_itwt_setup, the STA will send an ITWT setup frame, and start a timer to trigger the ITWT setup response frame sent from AP. If the AP can not send the setup response frame during 5s, STA will post an ITWT setup failed event. I don't think anything wrong with the TWT parameters, and if we set the wrong TWT parameters, AP also needs to send us the TWT response frame.
Hi @xuxiao111
Hmm...is there anything to be explored on the issue that I can call the esp_wifi_sta_itwt_setup hundreds of times (I just leave my code running - call it every couple seconds after getting the timeout error) and only see the frame on wireshark from the ESP32 sent out once, maybe twice over a period of >30mins? Or is this also possibly an AP issue?
When running other examples like MQTT, wireshark never seems to miss a frame that the ESP32 sends.
Is there a list of APs that have been tested specifically with the ESP32C6 in TWT mode? Or at least maybe just the one you're using? Might be a good sanity check for me to buy one though I'd be very surprised if an enterprise level WIFI 6 AP with the latest firmware can't respond to these commands...
Hi @emc-vishaal AP list:
Another router that is known to work is TP-Link Archer AX73.
Thanks @xuxiao111 @igrr I've decided to go another direction on this project temporarily and not use the ESP32 or Wifi6...inconsistent TWT behavior between APs when setting up TWT turns the whole thing into a a no-go at this point but I'll likely revisit this in the near future. I'll close this thread for now
Sorry reopen this issue, but i'm with a project that one option is implement ESP32-C6 with TWT. Is there any other router, besides the ones listed above in this issue, known to support iTWT? @igrr @xuxiao111
Hi @emc-vishaal
We have tested the following APs and they all support itwt.
AP List:
@xuxiao111 I got a TP-Link Archer AX73, and itwt example now works. Thank you.
However I figured out that any combination of mantissa and exponent, to set iTWT interval, that exceeds 0x7FFFFFFF i got:
W (3269) wifi:(itwt)rx response, unexpected setup command:7(reject)
E (3269) itwt: <WIFI_EVENT_ITWT_SETUP>twt_id:0, twt setup request was rejected, setup cmd: 7
any value under 0x7FFFFFFF, but that exceeds 0x80000, turns into a combination of a mantissa with exponent 13 that have the same value as set.
if above condition is met and the value is a bit bigger than 0x20000000, like 32770*2^14(0x20008000) i got:
E (2650) wifi:(itwt)recv invalid iTWT parameters SP: 32768 < WD: 65280
E (2651) itwt: <WIFI_EVENT_ITWT_SETUP>twt_id:0, twt setup failed, status: 258
if value exceeds 0x20000000 by a bit more, like 32780*2^14(0x20030000), the value turns to = value modulo 0x20000000, looks like buffer overflows.
if value is equal 0x20000000, the router crashes.
Hi @VitorBFreitas, I'm sorry for not getting back to you sooner. Can you help check if the fields in the TWT action replied to by the AP are correct by capturing packets?
Hello @xuxiao111, I got a hard time trying to capture beacon frames with wireshark in windows, I only managed to get broadcast packets with Acrylic Wi-Fi and parse the data with wireshark. I'm not sure for what should I looking for, appreciate if you can help me.
Below follows two random prints of a captured packet, hope it helps with something:
Hello, @xuxiao111. Can you provide me some help here?
Hi @VitorBFreitas, The beacon frame does not carry TWT setup related parameters, just the flag to tell the station, the AP supports TWT.
We need to capture the TWT setup response frame sent by AP to check whether the AP response is correct. From the log you print, it seems the AP response has incorrect parameters.
We need to capture the TWT setup response frame sent by AP to check whether the AP response is correct. From the log you print, it seems the AP response has incorrect parameters.
Can you point me what should I look for in the print that shows that the response has incorrect parameters?
From this "E (2650) wifi:(itwt)recv invalid iTWT parameters SP: 32768 < WD: 65280".
looks like the TWT cycle time is 32.768ms, but the wakeup time is 65.280ms. It's incorrect.
And for this "any value under 0x7FFFFFFF, but that exceeds 0x80000, turns into a combination of a mantissa with exponent 13 that have the same value as set.". The actual TWT parameters used are obtained from the TWT setup response frame sent from the AP.
From this "E (2650) wifi:(itwt)recv invalid iTWT parameters SP: 32768 < WD: 65280".
looks like the TWT cycle time is 32.768ms, but the wakeup time is 65.280ms. It's incorrect.
And for this "any value under 0x7FFFFFFF, but that exceeds 0x80000, turns into a combination of a mantissa with exponent 13 that have the same value as set.". The actual TWT parameters used are obtained from the TWT setup response frame sent from the AP.
Got it. So should I assume that the TP-Link Archer AX73 is the problem, right?
yeah, so I want to know the TWT setup parameters sent from AP to double-check.
@xuxiao111 Sounds that you are right. Here is the setup parameters sent to ap and from ap.
Answers checklist.
IDF version.
v5.1
Operating System used.
Linux
How did you build your project?
Command line with idf.py
If you are using Windows, please specify command line type.
None
Development Kit.
ESP32-C6-DevKitC-1
Power Supply used.
USB
What is the expected behavior?
Expect ESP32 to connect to WiFi 6 capable AP and negotiate at TWT setup (though I am not sure what the console output should look like...Readme.MD shows no expected results)
What is the actual behavior?
Error 0x3018 - TWT Setup timeout
Steps to reproduce.
Debug Logs.
More Information.
My main goal is to get this example running and integrate TWT/light sleep mode into a project where I want the ESP32 to sleep and wake up every few seconds and use TWT to grab whatever data the access point has waiting for it.
ESP32 is connected via WIFI6 to the access point properly. Using DHCP instead of the static IP in the configuration. Everything else in sdkconfig is left on defaults.
The 0x3018 error is TWT setup timeout (consistently happens 5 sec after GOT_IP event) - I placed this print statement in the itwt setup handler function after it casts the event_data argument into type (wifi_event_sta_itwt_setup_t *)
I tried to look at the code in got_ip_handler but it seems like none of the source files lead to the source code for esp_wifi_sta_itwt_setup - I can only see the prototype defined in esp_wifi_he.h
I guess the ESP32 can't receive the response packet from the TWT setup for some reason?
Any help is appreciated, thank you!