espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.43k stars 7.25k forks source link

ESP32C6/WiFi 6 ITWT example stops after TWT setup attempt (IDFGH-10557) #11797

Closed emc-vishaal closed 1 year ago

emc-vishaal commented 1 year ago

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.

  1. Set the target using idf.py set-target esp32c6
  2. build using idf.py build
  3. flash using idf.py flash -p /dev/ttyUSB0 monitor
  4. wait for example to run

Debug Logs.

ESP-ROM:esp32c6-20220919
Build:Sep 19 2022
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:2
load:0x4086c410,len:0xd48
load:0x4086e610,len:0x2d68
load:0x40875720,len:0x17ec
entry 0x4086c410
I (23) boot: ESP-IDF v5.1-dirty 2nd stage bootloader[0m
I (24) boot: compile time Jul  4 2023 14:18:55[0m
I (24) boot: chip revision: v0.0[0m
I (27) boot.esp32c6: SPI Speed      : 40MHz[0m
I (32) boot.esp32c6: SPI Mode       : DIO[0m
I (36) boot.esp32c6: SPI Flash Size : 2MB[0m
I (41) boot: Enabling RNG early entropy source...[0m
I (47) boot: Partition Table:[0m
I (50) boot: ## Label            Usage          Type ST Offset   Length[0m
I (57) boot:  0 nvs              WiFi data        01 02 00009000 00006000[0m
I (65) boot:  1 phy_init         RF data          01 01 0000f000 00001000[0m
I (72) boot:  2 factory          factory app      00 00 00010000 00100000[0m
I (80) boot: End of partition table[0m
I (84) esp_image: segment 0: paddr=00010020 vaddr=42090020 size=25930h (153904) map[0m
I (124) esp_image: segment 1: paddr=00035958 vaddr=40800000 size=026c0h (  9920) load[0m
I (127) esp_image: segment 2: paddr=00038020 vaddr=42000020 size=882c4h (557764) map[0m
I (243) esp_image: segment 3: paddr=000c02ec vaddr=408026c0 size=14354h ( 82772) load[0m
I (263) esp_image: segment 4: paddr=000d4648 vaddr=50000000 size=00068h (   104) load[0m
I (268) boot: Loaded app from partition at offset 0x10000[0m
I (268) boot: Disabling RNG early entropy source...[0m
I (283) cpu_start: Unicore app[0m
I (283) cpu_start: Pro cpu up.[0m
W (292) clk: esp_perip_clk_init() has not been implemented yet[0m
I (298) cpu_start: Pro cpu start user code[0m
I (299) cpu_start: cpu freq: 80000000 Hz[0m
I (299) cpu_start: Application information:[0m
I (301) cpu_start: Project name:     itwt[0m
I (306) cpu_start: App version:      1[0m
I (311) cpu_start: Compile time:     Jul  4 2023 18:08:46[0m
I (317) cpu_start: ELF file SHA256:  9543b602574daae6...[0m
I (323) cpu_start: ESP-IDF:          v5.1-dirty[0m
I (328) cpu_start: Min chip rev:     v0.0[0m
I (332) cpu_start: Max chip rev:     v0.99 [0m
I (337) cpu_start: Chip rev:         v0.0[0m
I (342) heap_init: Initializing. RAM available for dynamic allocation:[0m
I (349) heap_init: At 4081B0D0 len 00061540 (389 KiB): D/IRAM[0m
I (356) heap_init: At 4087C610 len 00002F54 (11 KiB): STACK/DIRAM[0m
I (362) heap_init: At 50000078 len 00003F88 (15 KiB): RTCRAM[0m
I (370) spi_flash: detected chip: generic[0m
I (373) spi_flash: flash io: dio[0m
W (377) spi_flash: Detected size(8192k) larger than the size in the binary image header(2048k). Using the size in the binary image header.[0m
I (391) sleep: Enable automatic switching of GPIO sleep configuration[0m
I (398) sleep_clock: System Power, Clock and Reset sleep retention initialization[0m
I (406) sleep_clock: Modem Power, Clock and Reset sleep retention initialization[0m
I (414) sleep_sys_periph: Interrupt Matrix sleep retention initialization[0m
I (422) sleep_sys_periph: HP System sleep retention initialization[0m
I (429) sleep_sys_periph: TEE/APM sleep retention initialization[0m
I (435) sleep_sys_periph: UART sleep retention initialization[0m
I (442) sleep_sys_periph: Timer Group sleep retention initialization[0m
I (449) sleep_sys_periph: IO Matrix sleep retention initialization[0m
I (456) sleep_sys_periph: SPI Mem sleep retention initialization[0m
I (463) sleep_sys_periph: SysTimer sleep retention initialization[0m
I (480) coexist: coex firmware version: ebddf30[0m
I (480) coexist: coexist rom version 5b8dcfa[0m
I (481) app_start: Starting scheduler on CPU0[0m
I (484) main_task: Started on CPU0[0m
I (488) main_task: Calling app_main()[0m
I (492) itwt_main: APP_MAIN_STARTED[0m
I (510) pm: Frequency switching config: CPU_MAX: 80, APB_MAX: 80, APB_MIN: 10, Light sleep: ENABLED[0m
I (513) pp: pp rom version: 5b8dcfa[0m
I (513) net80211: net80211 rom version: 5b8dcfa[0m
I (520) wifi:wifi driver task: 408234f4, prio:23, stack:6656, core=0
I (525) wifi:wifi firmware version: 6a2a12b
I (528) wifi:wifi certification version: v7.0
I (532) wifi:config NVS flash: disabled
I (536) wifi:config nano formating: disabled
I (540) wifi:mac_version:HAL_MAC_ESP32AX_761,ut_version:N
I (545) wifi:Init data frame dynamic rx buffer num: 38
I (550) wifi:Init management frame dynamic rx buffer num: 38
I (555) wifi:Init management short buffer num: 32
I (560) wifi:Init dynamic tx buffer num: 35
I (564) wifi:Init static tx FG buffer num: 2
I (568) wifi:Init static rx buffer size: 1700
I (572) wifi:Init static rx buffer num: 20
I (575) wifi:Init dynamic rx buffer num: 38
I (581) wifi_init: rx ba win: 20[0m
I (583) wifi_init: tcpip mbox: 64[0m
I (587) wifi_init: udp mbox: 64[0m
I (591) wifi_init: tcp mbox: 64[0m
I (595) wifi_init: tcp tx win: 30000[0m
I (599) wifi_init: tcp rx win: 34000[0m
I (603) wifi_init: tcp mss: 1440[0m
I (607) wifi_init: WiFi IRAM OP enabled[0m
I (612) wifi_init: WiFi RX IRAM OP enabled[0m
I (617) wifi_init: WiFi SLP IRAM OP enabled[0m
I (623) wifi:Set ps type: 1

I (624) phy_init: phy_version 202,b4b3263,May 17 2023,20:14:14[0m
W (678) esp_adapter: wifi_reset_mac_wrapper() has not been implemented yet[0m
W (681) wifi:(bf)761:0x600a7cac:0x01b4b4b0
W (681) wifi:(agc)0x600a7128:0xd2151800, min.avgNF:0xce->0xd2(dB), RCalCount:0x151, min.RRssi:0x800(-128.00)
W (688) wifi:(TB)WDEV_PWR_TB_MCS0:19
W (691) wifi:(TB)WDEV_PWR_TB_MCS1:19
W (695) wifi:(TB)WDEV_PWR_TB_MCS2:19
W (698) wifi:(TB)WDEV_PWR_TB_MCS3:19
W (701) wifi:(TB)WDEV_PWR_TB_MCS4:19
W (705) wifi:(TB)WDEV_PWR_TB_MCS5:19
W (708) wifi:(TB)WDEV_PWR_TB_MCS6:18
W (711) wifi:(TB)WDEV_PWR_TB_MCS7:18
W (714) wifi:(TB)WDEV_PWR_TB_MCS8:17
W (718) wifi:(TB)WDEV_PWR_TB_MCS9:15
W (721) wifi:(TB)WDEV_PWR_TB_MCS10:15
W (724) wifi:(TB)WDEV_PWR_TB_MCS11:15
I (728) wifi:11ax coex: WDEVAX_PTI0(0x55777555), WDEVAX_PTI1(0x00003377).

I (735) wifi:mode : sta (40:4c:ca:41:83:98)
I (738) wifi:enable tsf
I (743) itwt_main: sta connect to EMCJPN[0m
I (750) main_task: Returned from app_main()[0m
I (1958) wifi:(mac)omc_ul_mu_data_disable_rx:0
I (1958) wifi:(phy)ppe_thresholds_present:1, nominal_packet_padding:0
I (1958) wifi:(phy)dcm tx(constellation:0, nss:0), dcm rx(constellation:1, nss:0)
I (1964) wifi:(phy)rx_mcs_map:0xffaa(for_1_ss:2), tx_mcs_map:0xffaa, stbc_tx:1, bfmer(su:1, mu:1), ldpc:1
I (1974) wifi:(phy)nsts:3, ru_index_bitmap:0x3(242:1, 484:1, 996:0, 2*996:0)
I (1980) wifi:(phy)threshold_bits:48, nsts_num:4, ru_num:2, he_cap->len:29, ppe_threshold_len:7(6,11,4)
I (1990) wifi:(ppe)RU242, NSTS0, PPE16:0, PPE8:7, nominal_packet_padding:2
I (1996) wifi:(opr)len:7, TWT Required:0, VHT Operation Present:0, 6GHz Info Present:0, Co-Hosted BSS:0, Basic MCS and NSS:0xfffc
I (2007) wifi:(opr)len:7, Default PE Duration:4, TXOP RTS Threshold:1023(0 us), ER-SU-Disable:0
I (2016) wifi:(opr)len:7, BSS Color:13, disabled:0, Partial BSS Color:0
I (2022) wifi:(spr)len:2, ctrl:0x3, PSR Disallowed:1, Non-SRG OBSS PD SR Disallowed:1
I (2030) wifi:(spr)len:2, ctrl:0x3, Non-SRG Offset Present:0, SRG Info Present:0
I (2041) wifi:new:<11,0>, old:<1,0>, ap:<255,255>, sta:<11,0>, prof:1
I (2045) wifi:(connect)dot11_authmode:0x6, pairwise_cipher:0x3, group_cipher:0x3
I (2051) wifi:state: init -> auth (b0)
I (3727) wifi:state: auth -> assoc (0)
E (3735) wifi:Association refused temporarily, comeback time 1024 mSec
I (4760) wifi:state: assoc -> assoc (0)
I (5760) wifi:state: assoc -> init (200)
I (5761) wifi:new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
I (5762) itwt_main: sta disconnect, reconnect...[0m
I (6495) wifi:(mac)omc_ul_mu_data_disable_rx:0
I (6495) wifi:(phy)ppe_thresholds_present:1, nominal_packet_padding:0
I (6496) wifi:(phy)dcm tx(constellation:0, nss:0), dcm rx(constellation:1, nss:0)
I (6502) wifi:(phy)rx_mcs_map:0xffaa(for_1_ss:2), tx_mcs_map:0xffaa, stbc_tx:1, bfmer(su:1, mu:1), ldpc:1
I (6511) wifi:(phy)nsts:3, ru_index_bitmap:0x3(242:1, 484:1, 996:0, 2*996:0)
I (6518) wifi:(phy)threshold_bits:48, nsts_num:4, ru_num:2, he_cap->len:29, ppe_threshold_len:7(6,11,4)
I (6527) wifi:(ppe)RU242, NSTS0, PPE16:0, PPE8:7, nominal_packet_padding:2
I (6534) wifi:(opr)len:7, TWT Required:0, VHT Operation Present:0, 6GHz Info Present:0, Co-Hosted BSS:0, Basic MCS and NSS:0xfffc
I (6545) wifi:(opr)len:7, Default PE Duration:4, TXOP RTS Threshold:1023(0 us), ER-SU-Disable:0
I (6553) wifi:(opr)len:7, BSS Color:42, disabled:0, Partial BSS Color:0
I (6560) wifi:(spr)len:2, ctrl:0x3, PSR Disallowed:1, Non-SRG OBSS PD SR Disallowed:1
I (6567) wifi:(spr)len:2, ctrl:0x3, Non-SRG Offset Present:0, SRG Info Present:0
I (6576) wifi:new:<6,0>, old:<11,0>, ap:<255,255>, sta:<6,0>, prof:1
I (6581) wifi:(connect)dot11_authmode:0x6, pairwise_cipher:0x3, group_cipher:0x3
I (6588) wifi:state: init -> auth (b0)
I (8271) wifi:state: auth -> assoc (0)
E (8287) wifi:Association refused temporarily, comeback time 1024 mSec
I (9311) wifi:state: assoc -> assoc (0)
I (10312) wifi:state: assoc -> init (200)
I (10312) wifi:new:<6,0>, old:<6,0>, ap:<255,255>, sta:<6,0>, prof:1
I (10313) itwt_main: sta disconnect, reconnect...[0m
I (12724) itwt_main: sta disconnect, reconnect...[0m
I (12739) wifi:(mac)omc_ul_mu_data_disable_rx:0
I (12740) wifi:(phy)ppe_thresholds_present:1, nominal_packet_padding:0
I (12740) wifi:(phy)dcm tx(constellation:0, nss:0), dcm rx(constellation:1, nss:0)
I (12746) wifi:(phy)rx_mcs_map:0xffaa(for_1_ss:2), tx_mcs_map:0xffaa, stbc_tx:1, bfmer(su:1, mu:1), ldpc:1
I (12756) wifi:(phy)nsts:3, ru_index_bitmap:0x3(242:1, 484:1, 996:0, 2*996:0)
I (12763) wifi:(phy)threshold_bits:48, nsts_num:4, ru_num:2, he_cap->len:29, ppe_threshold_len:7(6,11,4)
I (12772) wifi:(ppe)RU242, NSTS0, PPE16:0, PPE8:7, nominal_packet_padding:2
I (12779) wifi:(opr)len:7, TWT Required:0, VHT Operation Present:0, 6GHz Info Present:0, Co-Hosted BSS:0, Basic MCS and NSS:0xfffc
I (12790) wifi:(opr)len:7, Default PE Duration:4, TXOP RTS Threshold:1023(0 us), ER-SU-Disable:0
I (12798) wifi:(opr)len:7, BSS Color:42, disabled:0, Partial BSS Color:0
I (12805) wifi:(spr)len:2, ctrl:0x3, PSR Disallowed:1, Non-SRG OBSS PD SR Disallowed:1
I (12813) wifi:(spr)len:2, ctrl:0x3, Non-SRG Offset Present:0, SRG Info Present:0
I (12821) wifi:new:<6,0>, old:<6,0>, ap:<255,255>, sta:<6,0>, prof:1
I (12826) wifi:(connect)dot11_authmode:0x6, pairwise_cipher:0x3, group_cipher:0x3
I (12834) wifi:state: init -> auth (b0)
I (14560) wifi:state: auth -> assoc (0)
I (15561) wifi:state: assoc -> init (2700)
I (15562) wifi:new:<6,0>, old:<6,0>, ap:<255,255>, sta:<6,0>, prof:1
I (15563) itwt_main: sta disconnect, reconnect...[0m
I (16782) wifi:(mac)omc_ul_mu_data_disable_rx:0
I (16782) wifi:(phy)ppe_thresholds_present:1, nominal_packet_padding:0
I (16783) wifi:(phy)dcm tx(constellation:0, nss:0), dcm rx(constellation:1, nss:0)
I (16789) wifi:(phy)rx_mcs_map:0xffaa(for_1_ss:2), tx_mcs_map:0xffaa, stbc_tx:1, bfmer(su:1, mu:1), ldpc:1
I (16799) wifi:(phy)nsts:3, ru_index_bitmap:0x3(242:1, 484:1, 996:0, 2*996:0)
I (16805) wifi:(phy)threshold_bits:48, nsts_num:4, ru_num:2, he_cap->len:29, ppe_threshold_len:7(6,11,4)
I (16815) wifi:(ppe)RU242, NSTS0, PPE16:0, PPE8:7, nominal_packet_padding:2
I (16821) wifi:(opr)len:7, TWT Required:0, VHT Operation Present:0, 6GHz Info Present:0, Co-Hosted BSS:0, Basic MCS and NSS:0xfffc
I (16833) wifi:(opr)len:7, Default PE Duration:4, TXOP RTS Threshold:1023(0 us), ER-SU-Disable:0
I (16841) wifi:(opr)len:7, BSS Color:13, disabled:0, Partial BSS Color:0
I (16848) wifi:(spr)len:2, ctrl:0x3, PSR Disallowed:1, Non-SRG OBSS PD SR Disallowed:1
I (16855) wifi:(spr)len:2, ctrl:0x3, Non-SRG Offset Present:0, SRG Info Present:0
I (16865) wifi:new:<11,0>, old:<6,0>, ap:<255,255>, sta:<11,0>, prof:1
I (16869) wifi:(connect)dot11_authmode:0x6, pairwise_cipher:0x3, group_cipher:0x3
I (16876) wifi:state: init -> auth (b0)
I (18561) wifi:state: auth -> assoc (0)
I (18578) wifi:Extended Capabilities length:8, subtype:0x10, c0:c9:e3:a2:e9:d4, Operating mode notification Support
I (18579) wifi:state: assoc -> run (10)
I (18581) wifi:(he)ppe_thresholds_present:1, nominal_packet_padding(rx:0, cfg:2)
I (18588) wifi:(trc)phytype:CBW20-SGI, snr:58, maxRate:86, highestRateIdx:0
I (18595) wifi:(trc)rate(S-MCS7, schedIdx:0), ampdu(rate:S-MCS7, schedIdx(0, stop:8)), snr:58, ampduState:wait operational
I (18606) wifi:ifidx:0, rssi:-33, nf:-91, phytype(0x3, CBW20-SGI), phymode(0x5, 11ax), max_rate:860, he:1
I (18615) wifi:max ampdu length exponent:3(65535 bytes), mmss:0(no restriction)
I (18641) wifi:(extcap)mbssid:0, enhanced_mbssid_advertise:0, complete_nontxbssid_profiles:0
I (18641) wifi:connected with EMCJPN, aid = 2, channel 11, BW20, bssid = c0:c9:e3:a2:e9:d4
I (18646) wifi:cipher(pairwise:0x3, group:0x3), pmf:1, security:WPA3-SAE, phy:11ax, rssi:-33
I (18655) wifi:pm start, type: 1, itwt_start:0

I (18659) wifi:pm start, type:1, aid:0x2, trans-BSSID:c0:c9:e3:a2:e9:d4, BSSID[5]:0xd4, mbssid(max-indicator:0, index:0), he:1
I (18670) wifi:set rx beacon pti, rx_bcn_pti: 10, bcn_timeout: 25000, mt_pti: 10, mt_time: 10000
I (18680) wifi:[ADDBA]TX addba request, tid:0, dialogtoken:1, bufsize:32, A-MSDU:0(not supported), policy:1(IMR), ssn:0(0x0)
I (18690) wifi:[ADDBA]TX addba request, tid:7, dialogtoken:2, bufsize:32, A-MSDU:0(not supported), policy:1(IMR), ssn:0(0x30)
I (18701) wifi:[ADDBA]TX addba request, tid:5, dialogtoken:3, bufsize:32, A-MSDU:0(not supported), policy:1(IMR), ssn:0(0x0)
I (18714) wifi:[ADDBA]RX addba response, status:0, tid:0/tb:1(0xa1), bufsize:32, batimeout:0, txa_wnd:32
I (18721) wifi:[ADDBA]RX addba response, status:0, tid:7/tb:1(0xa1), bufsize:32, batimeout:0, txa_wnd:32
I (18730) wifi:[ADDBA]RX addba response, status:0, tid:5/tb:1(0xa1), bufsize:32, batimeout:0, txa_wnd:32
W (18740) wifi:<ba-add>idx:0, ifx:0, tid:0, TAHI:0x100d4e9, TALO:0xa2e3c9c0, (ssn:0, win:64, cur_ssn:0), CONF:0xc0000005
I (18750) wifi:BcnInt:102400, DTIM:1
I (19756) esp_netif_handlers: sta ip: 192.168.100.228, mask: 255.255.255.0, gw: 192.168.100.1[0m
I (24880) MAIN_DEBUG: 3018[0m
E (24881) itwt_main: <WIFI_EVENT_ITWT_SETUP>twt_id:5, unexpected setup command:0[0m

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!

xuxiao111 commented 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?

emc-vishaal commented 1 year ago

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?)

xuxiao111 commented 1 year ago

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. Screenshot from 2023-07-05 10-29-42

emc-vishaal commented 1 year ago

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

xuxiao111 commented 1 year ago

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?

emc-vishaal commented 1 year ago

Hi @xuxiao111

It appears our AP does support ITWT according to the beacon frame read in wireshark: Screenshot from 2023-07-06 11-57-57

xuxiao111 commented 1 year ago

Hi @emc-vishaal, can you help to capture the itwt setup response frame sent by AP? image

emc-vishaal commented 1 year ago

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: Screenshot from 2023-07-06 16-05-56

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.

xuxiao111 commented 1 year ago

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)

emc-vishaal commented 1 year ago

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. Screenshot from 2023-07-06 17-14-00

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?

xuxiao111 commented 1 year ago

image Wireshark version: image

emc-vishaal commented 1 year ago

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 Screenshot from 2023-07-07 14-48-20

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

xuxiao111 commented 1 year ago

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.

emc-vishaal commented 1 year ago

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

xuxiao111 commented 1 year ago

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.

emc-vishaal commented 1 year ago

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...

xuxiao111 commented 1 year ago

Hi @emc-vishaal AP list:

  1. AUSU: RT-AX56U
  2. AUSU: RT-AX86U
  3. AUSU: RT-AX88U
  4. Linksys: MX5300
  5. Linksys: MX4200 We have tested the above APs and can support ITWT. Normally, every time you call this function, there should be an ITWT setup frame sent from ESP32C6. And also, we have tested twt setup function with RT-AX56U, and it works fine. image branch: release/v5.1 (71a5663786)
igrr commented 1 year ago

Another router that is known to work is TP-Link Archer AX73.

emc-vishaal commented 1 year ago

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

VitorBFreitas commented 8 months ago

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

xuxiao111 commented 8 months ago

Hi @emc-vishaal

We have tested the following APs and they all support itwt.

AP List:

  1. ASUS_RT-AX86U
  2. Linksys_MX4200
  3. MIFON_X1-XR2142T
  4. Linksys_E9450
  5. Linksys_MX5300
  6. Linksys_MR7350
  7. H3C_NX54
  8. ASUS_XD4R
  9. TPLink_TL-XTR7880
  10. XiaoDu_XD-INA12-2001
  11. TPLink_TL-XDR5430
  12. ASUS_RT-AX56U
  13. NETGEAR_RAX120
  14. 360_V6
  15. ASUS_RT-AX89X
  16. ASUS_RT-AX82U
  17. H3C_BX54
  18. ASUS_GS-AX5400
  19. Mi_RA70
  20. Tenda_AX12
  21. ASUS_RT-AX88U
  22. ASUS_XT8
VitorBFreitas commented 8 months ago

@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.

xuxiao111 commented 7 months ago

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?

VitorBFreitas commented 7 months ago

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: wireshark1 wireshark2

VitorBFreitas commented 7 months ago

Hello, @xuxiao111. Can you provide me some help here?

xuxiao111 commented 7 months ago

Hi @VitorBFreitas, The beacon frame does not carry TWT setup related parameters, just the flag to tell the station, the AP supports TWT.

xuxiao111 commented 7 months ago

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.

VitorBFreitas commented 7 months ago

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?

xuxiao111 commented 7 months ago

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.

VitorBFreitas commented 7 months ago

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?

xuxiao111 commented 7 months ago

yeah, so I want to know the TWT setup parameters sent from AP to double-check.

VitorBFreitas commented 6 months ago

@xuxiao111 Sounds that you are right. Here is the setup parameters sent to ap and from ap. imagem (1)

imagem (2)