Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wi-Fi AP+STA mode not working on esp32c6 with Wi-Fi 6 AP (IDFGH-12689) #13679

Open
3 tasks done
alerighi opened this issue Apr 23, 2024 · 7 comments
Open
3 tasks done
Assignees
Labels
Status: Opened Issue is new Type: Bug bugs in IDF

Comments

@alerighi
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.2.1

Espressif SoC revision.

esp32c6

Operating System used.

macOS

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?

When configuring the board to activate both the AP mode and the STA mode (WIFI_MODE_APSTA) the STA connection to a Wi-Fi AP (in my case an Ubiquity Unifi U6-Pro) does initially succeed (the device gets an IP address), but when making the first network request it fails. Note that the connection to the same AP works correctly if only the STA mode is activated (WIFI_MODE_STA).

What is the actual behavior?

The AP connect successfully and network requests succeed.

Steps to reproduce.

I've was able to reproduce the issue by modifying the example "softap_sta" by adding an HTTP request at the end.

/*
 * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
 *
 * SPDX-License-Identifier: Unlicense OR CC0-1.0
 */
/*  WiFi softAP & station Example

   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
*/
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"

#include "esp_mac.h"
#include "esp_wifi.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_netif_net_stack.h"
#include "esp_netif.h"
#include "nvs_flash.h"
#include "lwip/inet.h"
#include "lwip/netdb.h"
#include "lwip/sockets.h"
#include "esp_http_client.h"

#if IP_NAPT
#include "lwip/lwip_napt.h"
#endif
#include "lwip/err.h"
#include "lwip/sys.h"

/* The examples use WiFi configuration that you can set via project configuration menu.

   If you'd rather not, just change the below entries to strings with
   the config you want - ie #define EXAMPLE_ESP_WIFI_STA_SSID "mywifissid"
*/

/* STA Configuration */
#define EXAMPLE_ESP_WIFI_STA_SSID CONFIG_ESP_WIFI_REMOTE_AP_SSID
#define EXAMPLE_ESP_WIFI_STA_PASSWD CONFIG_ESP_WIFI_REMOTE_AP_PASSWORD
#define EXAMPLE_ESP_MAXIMUM_RETRY CONFIG_ESP_MAXIMUM_STA_RETRY

#if CONFIG_ESP_WIFI_AUTH_OPEN
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_OPEN
#elif CONFIG_ESP_WIFI_AUTH_WEP
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WEP
#elif CONFIG_ESP_WIFI_AUTH_WPA_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_PSK
#elif CONFIG_ESP_WIFI_AUTH_WPA2_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_PSK
#elif CONFIG_ESP_WIFI_AUTH_WPA_WPA2_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_WPA2_PSK
#elif CONFIG_ESP_WIFI_AUTH_WPA3_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA3_PSK
#elif CONFIG_ESP_WIFI_AUTH_WPA2_WPA3_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_WPA3_PSK
#elif CONFIG_ESP_WIFI_AUTH_WAPI_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WAPI_PSK
#endif

/* AP Configuration */
#define EXAMPLE_ESP_WIFI_AP_SSID CONFIG_ESP_WIFI_AP_SSID
#define EXAMPLE_ESP_WIFI_AP_PASSWD CONFIG_ESP_WIFI_AP_PASSWORD
#define EXAMPLE_ESP_WIFI_CHANNEL CONFIG_ESP_WIFI_AP_CHANNEL
#define EXAMPLE_MAX_STA_CONN CONFIG_ESP_MAX_STA_CONN_AP

/* The event group allows multiple bits for each event, but we only care about two events:
 * - we are connected to the AP with an IP
 * - we failed to connect after the maximum amount of retries */
#define WIFI_CONNECTED_BIT BIT0
#define WIFI_FAIL_BIT BIT1

static const char *TAG = "HTTP";
static const char *TAG_AP = "WiFi SoftAP";
static const char *TAG_STA = "WiFi Sta";

static int s_retry_num = 0;

/* FreeRTOS event group to signal when we are connected/disconnected */
static EventGroupHandle_t s_wifi_event_group;

static void wifi_event_handler(void *arg, esp_event_base_t event_base,
                               int32_t event_id, void *event_data)
{
    if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_AP_STACONNECTED)
    {
        wifi_event_ap_staconnected_t *event = (wifi_event_ap_staconnected_t *)event_data;
        ESP_LOGI(TAG_AP, "Station " MACSTR " joined, AID=%d",
                 MAC2STR(event->mac), event->aid);
    }
    else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_AP_STADISCONNECTED)
    {
        wifi_event_ap_stadisconnected_t *event = (wifi_event_ap_stadisconnected_t *)event_data;
        ESP_LOGI(TAG_AP, "Station " MACSTR " left, AID=%d",
                 MAC2STR(event->mac), event->aid);
    }
    else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START)
    {
        esp_wifi_connect();
        ESP_LOGI(TAG_STA, "Station started");
    }
    else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP)
    {
        ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
        ESP_LOGI(TAG_STA, "Got IP:" IPSTR, IP2STR(&event->ip_info.ip));
        s_retry_num = 0;
        xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
    }
    else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_CONNECTED)
    {
        ESP_LOGI(TAG_STA, "STA Connected!!");
    }
    else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED)
    {
        wifi_event_sta_disconnected_t *event = (wifi_event_sta_disconnected_t *)event_data;

        ESP_LOGE(TAG_STA, "!! STA Disconnected! Reason: %d", event->reason);
    }
    else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_HOME_CHANNEL_CHANGE)
    {
        wifi_event_home_channel_change_t *event = (wifi_event_home_channel_change_t *)event_data;
        ESP_LOGI(TAG_STA, "Channel changed from %u to %u", event->old_chan, event->new_chan);
    }

    else
    {
        ESP_LOGI(TAG_STA, "unknown wifi event base %s id %ld", event_base, event_id);
    }
}

esp_err_t http_event_handler(esp_http_client_event_t *evt)
{
    switch (evt->event_id)
    {
    case HTTP_EVENT_ERROR:
        ESP_LOGD(TAG, "HTTP_EVENT_ERROR");
        break;
    case HTTP_EVENT_ON_CONNECTED:
        ESP_LOGD(TAG, "HTTP_EVENT_ON_CONNECTED");
        break;
    case HTTP_EVENT_HEADER_SENT:
        ESP_LOGD(TAG, "HTTP_EVENT_HEADER_SENT");
        break;
    case HTTP_EVENT_ON_HEADER:
        ESP_LOGD(TAG, "HTTP_EVENT_ON_HEADER, key=%s, value=%s", evt->header_key, evt->header_value);
        break;
    case HTTP_EVENT_ON_DATA:
        ESP_LOGD(TAG, "HTTP_EVENT_ON_DATA, len=%d", evt->data_len);
        break;
    case HTTP_EVENT_ON_FINISH:
        ESP_LOGD(TAG, "HTTP_EVENT_ON_FINISH");
        break;
    case HTTP_EVENT_DISCONNECTED:
        ESP_LOGI(TAG, "HTTP_EVENT_DISCONNECTED");
        break;
    case HTTP_EVENT_REDIRECT:
        ESP_LOGD(TAG, "HTTP_EVENT_REDIRECT");
        break;
    }
    return ESP_OK;
}

/* Initialize soft AP */
esp_netif_t *wifi_init_softap(void)
{
    esp_netif_t *esp_netif_ap = esp_netif_create_default_wifi_ap();

    wifi_config_t wifi_ap_config = {
        .ap = {
            .ssid = EXAMPLE_ESP_WIFI_AP_SSID,
            .ssid_len = strlen(EXAMPLE_ESP_WIFI_AP_SSID),
            .channel = EXAMPLE_ESP_WIFI_CHANNEL,
            .password = EXAMPLE_ESP_WIFI_AP_PASSWD,
            .max_connection = EXAMPLE_MAX_STA_CONN,
            .authmode = WIFI_AUTH_WPA2_PSK,
            .pmf_cfg = {
                .required = false,
            },
        },
    };

    if (strlen(EXAMPLE_ESP_WIFI_AP_PASSWD) == 0)
    {
        wifi_ap_config.ap.authmode = WIFI_AUTH_OPEN;
    }

    ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &wifi_ap_config));

    ESP_LOGI(TAG_AP, "wifi_init_softap finished. SSID:%s password:%s channel:%d",
             EXAMPLE_ESP_WIFI_AP_SSID, EXAMPLE_ESP_WIFI_AP_PASSWD, EXAMPLE_ESP_WIFI_CHANNEL);

    return esp_netif_ap;
}

/* Initialize wifi station */
esp_netif_t *wifi_init_sta(void)
{
    esp_netif_t *esp_netif_sta = esp_netif_create_default_wifi_sta();

    wifi_config_t wifi_sta_config = {
        .sta = {
            .ssid = EXAMPLE_ESP_WIFI_STA_SSID,
            .password = EXAMPLE_ESP_WIFI_STA_PASSWD,
            .scan_method = WIFI_ALL_CHANNEL_SCAN,
            .failure_retry_cnt = EXAMPLE_ESP_MAXIMUM_RETRY,
            /* Authmode threshold resets to WPA2 as default if password matches WPA2 standards (pasword len => 8).
             * If you want to connect the device to deprecated WEP/WPA networks, Please set the threshold value
             * to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set the password with length and format matching to
             * WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK standards.
             */
            .threshold.authmode = ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD,
            .sae_pwe_h2e = WPA3_SAE_PWE_BOTH,
        },
    };

    ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_sta_config));

    ESP_LOGI(TAG_STA, "wifi_init_sta finished.");

    return esp_netif_sta;
}

void app_main(void)
{
    ESP_ERROR_CHECK(esp_netif_init());
    ESP_ERROR_CHECK(esp_event_loop_create_default());

    // Initialize NVS
    esp_err_t ret = nvs_flash_init();
    if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND)
    {
        ESP_ERROR_CHECK(nvs_flash_erase());
        ret = nvs_flash_init();
    }
    ESP_ERROR_CHECK(ret);

    /* Initialize event group */
    s_wifi_event_group = xEventGroupCreate();

    /* Register Event handler */
    ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
                                                        ESP_EVENT_ANY_ID,
                                                        &wifi_event_handler,
                                                        NULL,
                                                        NULL));
    ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT,
                                                        IP_EVENT_STA_GOT_IP,
                                                        &wifi_event_handler,
                                                        NULL,
                                                        NULL));

    /*Initialize WiFi */
    wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
    ESP_ERROR_CHECK(esp_wifi_init(&cfg));

    ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_APSTA));

    /* Initialize AP */
    ESP_LOGI(TAG_AP, "ESP_WIFI_MODE_AP");
    esp_netif_t *esp_netif_ap = wifi_init_softap();

    /* Initialize STA */
    ESP_LOGI(TAG_STA, "ESP_WIFI_MODE_STA");
    esp_netif_t *esp_netif_sta = wifi_init_sta();

    /* Start WiFi */
    ESP_ERROR_CHECK(esp_wifi_start());

    /*
     * Wait until either the connection is established (WIFI_CONNECTED_BIT) or
     * connection failed for the maximum number of re-tries (WIFI_FAIL_BIT).
     * The bits are set by event_handler() (see above)
     */
    EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group,
                                           WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
                                           pdFALSE,
                                           pdFALSE,
                                           portMAX_DELAY);

    /* xEventGroupWaitBits() returns the bits before the call returned,
     * hence we can test which event actually happened. */
    if (bits & WIFI_CONNECTED_BIT)
    {
        ESP_LOGI(TAG_STA, "connected to ap SSID:%s password:%s",
                 EXAMPLE_ESP_WIFI_STA_SSID, EXAMPLE_ESP_WIFI_STA_PASSWD);
    }
    else if (bits & WIFI_FAIL_BIT)
    {
        ESP_LOGI(TAG_STA, "Failed to connect to SSID:%s, password:%s",
                 EXAMPLE_ESP_WIFI_STA_SSID, EXAMPLE_ESP_WIFI_STA_PASSWD);
    }
    else
    {
        ESP_LOGE(TAG_STA, "UNEXPECTED EVENT");
        return;
    }

    /* Set sta as the default interface */
    esp_netif_set_default_netif(esp_netif_sta);

    // /* Enable napt on the AP netif */
    // if (esp_netif_napt_enable(esp_netif_ap) != ESP_OK) {
    //     ESP_LOGE(TAG_STA, "NAPT not enabled on the netif: %p", esp_netif_ap);
    // }

    while (1)
    {
        esp_http_client_config_t config = {
            .host = "google.com",
            .path = "/",
            .query = "",
            .event_handler = http_event_handler,
            .user_data = NULL,
            .disable_auto_redirect = true,
        };
        esp_http_client_handle_t client = esp_http_client_init(&config);

        esp_err_t err = esp_http_client_perform(client);
        if (err == ESP_OK)
        {
            ESP_LOGI(TAG, "HTTP GET Status = %d, content_length = %" PRId64,
                     esp_http_client_get_status_code(client),
                     esp_http_client_get_content_length(client));
        }
        else
        {
            ESP_LOGE(TAG, "HTTP GET request failed: %s", esp_err_to_name(err));
        }

        vTaskDelay(pdMS_TO_TICKS(1000));
    }
}

Debug Logs.

rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:2
load:0x40875720,len:0x1804
load:0x4086c410,len:0xe58
load:0x4086e610,len:0x2e24
entry 0x4086c41a
I (23) boot: ESP-IDF v5.2.1 2nd stage bootloader
I (24) boot: compile time Apr 23 2024 12:31:49
I (24) boot: chip revision: v0.0
I (26) boot.esp32c6: SPI Speed      : 80MHz
I (31) boot.esp32c6: SPI Mode       : DIO
I (36) boot.esp32c6: SPI Flash Size : 2MB
I (41) boot: Enabling RNG early entropy source...
I (46) boot: Partition Table:
I (50) boot: ## Label            Usage          Type ST Offset   Length
I (57) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (64) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (72) boot:  2 factory          factory app      00 00 00010000 00100000
I (79) boot: End of partition table
I (83) esp_image: segment 0: paddr=00010020 vaddr=420b0020 size=278a0h (161952) map
I (125) esp_image: segment 1: paddr=000378c8 vaddr=40800000 size=00750h (  1872) load
I (127) esp_image: segment 2: paddr=00038020 vaddr=42000020 size=af7bch (718780) map
I (279) esp_image: segment 3: paddr=000e77e4 vaddr=40800750 size=15148h ( 86344) load
I (300) esp_image: segment 4: paddr=000fc934 vaddr=408158a0 size=0358ch ( 13708) load
I (309) boot: Loaded app from partition at offset 0x10000
I (310) boot: Disabling RNG early entropy source...
I (321) cpu_start: Unicore app
W (330) clk: esp_perip_clk_init() has not been implemented yet
I (337) cpu_start: Pro cpu start user code
I (337) cpu_start: cpu freq: 160000000 Hz
I (337) cpu_start: Application information:
I (340) cpu_start: Project name:     softap_sta
I (345) cpu_start: App version:      v5.2.1
I (350) cpu_start: Compile time:     Apr 23 2024 12:34:02
I (356) cpu_start: ELF file SHA256:  3559d5cb0...
I (361) cpu_start: ESP-IDF:          v5.2.1
I (366) cpu_start: Min chip rev:     v0.0
I (371) cpu_start: Max chip rev:     v0.99
I (376) cpu_start: Chip rev:         v0.0
I (381) heap_init: Initializing. RAM available for dynamic allocation:
I (388) heap_init: At 4081DFE0 len 0005E630 (377 KiB): RAM
I (394) heap_init: At 4087C610 len 00002F54 (11 KiB): RAM
I (400) heap_init: At 50000000 len 00003FE8 (15 KiB): RTCRAM
I (407) spi_flash: detected chip: generic
I (411) spi_flash: flash io: dio
W (415) spi_flash: Detected size(8192k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (428) sleep: Configure to isolate all GPIO pins in sleep state
I (435) sleep: Enable automatic switching of GPIO sleep configuration
I (442) coexist: coex firmware version: 77cd7f8
I (447) coexist: coexist rom version 5b8dcfa
I (452) main_task: Started on CPU0
I (452) main_task: Calling app_main()
I (462) pp: pp rom version: 5b8dcfa
I (472) net80211: net80211 rom version: 5b8dcfa
I (482) wifi:wifi driver task: 40826da0, prio:23, stack:6656, core=0
I (482) wifi:wifi firmware version: a9f5b59
I (482) wifi:wifi certification version: v7.0
I (482) wifi:config NVS flash: enabled
I (482) wifi:config nano formating: disabled
I (492) wifi:mac_version:HAL_MAC_ESP32AX_761,ut_version:N
I (492) wifi:Init data frame dynamic rx buffer num: 32
I (502) wifi:Init static rx mgmt buffer num: 5
I (502) wifi:Init management short buffer num: 32
I (512) wifi:Init dynamic tx buffer num: 32
I (512) wifi:Init static tx FG buffer num: 2
I (512) wifi:Init static rx buffer size: 1700
I (522) wifi:Init static rx buffer num: 10
I (522) wifi:Init dynamic rx buffer num: 32
I (532) wifi_init: rx ba win: 6
I (532) wifi_init: tcpip mbox: 32
I (532) wifi_init: udp mbox: 6
I (542) wifi_init: tcp mbox: 6
I (542) wifi_init: tcp tx win: 5760
I (552) wifi_init: tcp rx win: 5760
I (552) wifi_init: tcp mss: 1440
I (552) wifi_init: WiFi IRAM OP enabled
I (562) wifi_init: WiFi RX IRAM OP enabled
I (562) WiFi SoftAP: ESP_WIFI_MODE_AP
I (572) WiFi SoftAP: wifi_init_softap finished. SSID:TEST_NET password:TEST_NET channel:1
I (582) WiFi Sta: ESP_WIFI_MODE_STA
I (592) WiFi Sta: wifi_init_sta finished.
I (592) phy_init: phy_version 250,e14681b,Jan 24 2024,17:43:11
W (632) wifi:(bf)761:0x600a7cac:0x01b4b4b0
W (632) wifi:(agc)0x600a7128:0xd21da800, min.avgNF:0xce->0xd2(dB), RCalCount:0x1da, min.RRssi:0x800(-128.00)
W (642) wifi:(TB)WDEV_PWR_TB_MCS0:19
W (642) wifi:(TB)WDEV_PWR_TB_MCS1:19
W (642) wifi:(TB)WDEV_PWR_TB_MCS2:19
W (652) wifi:(TB)WDEV_PWR_TB_MCS3:19
W (652) wifi:(TB)WDEV_PWR_TB_MCS4:19
W (652) wifi:(TB)WDEV_PWR_TB_MCS5:19
W (662) wifi:(TB)WDEV_PWR_TB_MCS6:18
W (662) wifi:(TB)WDEV_PWR_TB_MCS7:18
W (662) wifi:(TB)WDEV_PWR_TB_MCS8:17
W (672) wifi:(TB)WDEV_PWR_TB_MCS9:15
W (672) wifi:(TB)WDEV_PWR_TB_MCS10:15
W (672) wifi:(TB)WDEV_PWR_TB_MCS11:15
I (682) wifi:11ax coex: WDEVAX_PTI0(0x55777555), WDEVAX_PTI1(0x00003377).

I (682) wifi:mode : sta (40:4c:ca:41:83:10) + softAP (40:4c:ca:41:83:11)
I (692) wifi:enable tsf
I (692) wifi:Total power save buffer number: 16
I (692) wifi:Init max length of beacon: 752/752
I (702) wifi:Init max length of beacon: 752/752
I (702) WiFi Sta: Channel changed from 0 to 1
I (712) WiFi Sta: Station started
I (712) WiFi Sta: unknown wifi event base WIFI_EVENT id 12
I (722) wifi:(mac)omc_ul_mu_data_disable_rx:0
I (722) wifi:(phy)ppe_thresholds_present:1, nominal_packet_padding:0
I (732) wifi:(phy)dcm tx(constellation:0, nss:0), dcm rx(constellation:1, nss:0)
I (742) wifi:(phy)rx_mcs_map:0xfffa(for_1_ss:2), tx_mcs_map:0xfffa, stbc_tx:0, bfmer(su:1, mu:0), ldpc:1
I (752) wifi:(phy)nsts:1, ru_index_bitmap:0x3(242:1, 484:1, 996:0, 2*996:0)
I (752) wifi:(phy)threshold_bits:24, nsts_num:2, ru_num:2, he_cap->len:26, ppe_threshold_len:4(6,11,4)
I (762) wifi:(ppe)RU242, NSTS0, PPE16:0, PPE8:7, nominal_packet_padding:2
I (772) 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 (782) wifi:(opr)len:7, Default PE Duration:4, TXOP RTS Threshold:1023(0 us), ER-SU-Disable:0
I (792) wifi:(opr)len:7, BSS Color:56, disabled:0, Partial BSS Color:0
I (792) wifi:(spr)len:2, ctrl:0x3, PSR Disallowed:1, Non-SRG OBSS PD SR Disallowed:1
I (802) wifi:(spr)len:2, ctrl:0x3, Non-SRG Offset Present:0, SRG Info Present:0
I (812) esp_netif_lwip: DHCP server started on interface WIFI_AP_DEF with IP: 192.168.4.1
I (3542) wifi:new:<1,1>, old:<1,1>, ap:<1,1>, sta:<1,0>, prof:1
I (3542) wifi:(connect)dot11_authmode:0x3, pairwise_cipher:0x3, group_cipher:0x3
I (3902) wifi:state: init -> auth (b0)
I (3912) wifi:state: auth -> assoc (0)
I (3932) wifi:Extended Capabilities length:10, subtype:0x10, 60:22:32:e4:00:a2, Operating mode notification Support
I (3932) wifi:BSS max idle period 291, protected keep alive FALSE
I (3932) wifi:state: assoc -> run (10)
I (3932) wifi:(he)ppe_thresholds_present:1, nominal_packet_padding(rx:0, cfg:2)
I (3942) wifi:(trc)phytype:CBW20-SGI, snr:59, maxRate:86, highestRateIdx:0
I (3952) wifi:(trc)rate(S-MCS7, schedIdx:0), ampdu(rate:S-MCS7, schedIdx(0, stop:8)), snr:59, ampduState:wait operational
I (3962) wifi:ifidx:0, rssi:-37, nf:-96, phytype(0x3, CBW20-SGI), phymode(0x5, 11ax), max_rate:860, he:1
I (3972) wifi:max ampdu length exponent:3(65535 bytes), mmss:0(no restriction)
I (3992) wifi:(extcap)mbssid:0, enhanced_mbssid_advertise:0, complete_nontxbssid_profiles:0, twt_responder: 1
I (3992) wifi:connected with IOTINGA, aid = 22, channel 1, BW20, bssid = 60:22:32:e4:00:a2
I (4002) wifi:cipher(pairwise:0x3, group:0x3), pmf:0, security:WPA2-PSK, phy:11ax, rssi:-37
I (4012) wifi:pm start, type: 1, itwt_start:0

I (4012) wifi:pm start, type:1, aid:0x16, trans-BSSID:60:22:32:e4:00:a2, BSSID[5]:0xa2, mbssid(max-indicator:0, index:0), he:1
I (4022) wifi:dp: 1, bi: 102400, li: 3, scale listen interval from 307200 us to 307200 us
I (4032) wifi:set rx beacon pti, rx_bcn_pti: 10, bcn_timeout: 25000, mt_pti: 10, mt_time: 10000
I (4042) wifi:[ADDBA]TX addba request, tid:0, dialogtoken:1, bufsize:32, A-MSDU:0(not supported), policy:1(IMR), ssn:0(0x0)
I (4052) wifi:[ADDBA]TX addba request, tid:7, dialogtoken:2, bufsize:32, A-MSDU:0(not supported), policy:1(IMR), ssn:0(0x20)
I (4062) wifi:[ADDBA]TX addba request, tid:5, dialogtoken:3, bufsize:32, A-MSDU:0(not supported), policy:1(IMR), ssn:0(0x0)
I (4072) wifi:AP's beacon interval = 102400 us, DTIM period = 1
I (4072) WiFi Sta: STA Connected!!
I (4082) wifi:[ADDBA]RX addba response, status:0, tid:0/tb:1(0xa1), bufsize:32, batimeout:0, txa_wnd:32
I (4092) wifi:[ADDBA]RX addba response, status:0, tid:7/tb:1(0xa1), bufsize:32, batimeout:0, txa_wnd:32
I (4102) wifi:[ADDBA]RX addba response, status:0, tid:5/tb:1(0xa1), bufsize:32, batimeout:0, txa_wnd:32
I (5082) WiFi Sta: Got IP:10.17.100.159
I (5082) esp_netif_handlers: sta ip: 10.17.100.159, mask: 255.255.0.0, gw: 10.17.0.1
I (5082) WiFi Sta: connected to ap SSID:REDACTED password:REDACTED!
W (5102) wifi:<ba-add>idx:0, ifx:0, tid:6, TAHI:0x100a200, TALO:0xe4322260, (ssn:2, win:64, cur_ssn:2), CONF:0xc0006005
I (5462) wifi:<ba-del>idx:0, tid:6
W (5462) wifi:<ba-add>idx:0, ifx:0, tid:6, TAHI:0x100a200, TALO:0xe4322260, (ssn:2, win:64, cur_ssn:2), CONF:0xc0006005
I (5472) wifi:<ba-del>idx:0, tid:6
W (5472) wifi:<ba-add>idx:0, ifx:0, tid:6, TAHI:0x100a200, TALO:0xe4322260, (ssn:2, win:64, cur_ssn:2), CONF:0xc0006005
I (6542) wifi:<ba-del>idx:0, tid:6
W (6542) wifi:<ba-add>idx:0, ifx:0, tid:6, TAHI:0x100a200, TALO:0xe4322260, (ssn:2, win:64, cur_ssn:2), CONF:0xc0006005
I (6602) wifi:<ba-del>idx:0, tid:6
W (6602) wifi:<ba-add>idx:0, ifx:0, tid:6, TAHI:0x100a200, TALO:0xe4322260, (ssn:2, win:64, cur_ssn:2), CONF:0xc0006005
I (9602) wifi:state: run -> init (22c0)
I (9612) wifi:ifidx:0, rssi:-37, nf:-97, phytype(0x3, CBW20-SGI), phymode(0x5, 11ax), max_rate:860, he:1
I (9612) wifi:max ampdu length exponent:3(65535 bytes), mmss:0(no restriction)
I (9612) wifi:pm stop, total sleep time: 0 us / 5594825 us

I (9622) wifi:<ba-del>idx:0, tid:6
I (9622) wifi:new:<1,0>, old:<1,1>, ap:<1,1>, sta:<1,0>, prof:1
I (9632) WiFi Sta: Channel changed from 1 to 1
E (9632) WiFi Sta: !! STA Disconnected! Reason: 34
E (12092) esp-tls: couldn't get hostname for :google.com: getaddrinfo() returns 202, addrinfo=0x0
E (12092) transport_base: Failed to open a new connection: 32769
E (12092) HTTP_CLIENT: Connection failed, sock < 0
E (12102) HTTP: HTTP GET request failed: ESP_ERR_HTTP_CONNECT

More Information.

The disconnect reason seems to be WIFI_REASON_MISSING_ACKS. Here a screenshot of the AP settings. As you can see it's using the default settings.

AP_CONFIG

Thanks,
Alessandro

@alerighi alerighi added the Type: Bug bugs in IDF label Apr 23, 2024
@github-actions github-actions bot changed the title Wi-Fi AP+STA mode not working on esp32c6 with Wi-Fi 6 AP Wi-Fi AP+STA mode not working on esp32c6 with Wi-Fi 6 AP (IDFGH-12689) Apr 23, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Apr 23, 2024
@nishanth-radja
Copy link
Collaborator

nishanth-radja commented Apr 30, 2024

@alerighi can I have the commit ID of the IDF on which you are seeing this issue ? Also can you share the sniffer capture during the disconnection.

@xuxiao111
Copy link
Collaborator

Hi, @alerighi Thanks for reporting this issue, and sorry for the late response.
From the debug log, seems like the AP can not receive the ACK frame from the DUT (esp32c6), and then the AP sends the deauthentication to DUT, letting the DUT disconnect with the AP. I have tried to reproduce it in my testbed, but it works fine. Have you used other APs to test this case?

@alerighi
Copy link
Author

alerighi commented Apr 30, 2024

Hi,

the commit I'm using is the one corresponding to the 5.2.1 release:

commit a322e6bdad4b6675d4597fb2722eea2851ba88cb (HEAD, tag: v5.2.1)

Have you used other APs to test this case?

I've tried with other AP that are only Wi-Fi 4 2.4GHz and it works. The AP that I'm having issues so far is only the Ubiquity that I've mentioned above. This AP has configured a network that has both the band 2.4 and 5GHz and uses the Wi-Fi 6 standard.

I can try to reproduce the issue on another Wi-Fi AP that has Wi-Fi 6 networks, and I will get you back.

@nishanth-radja
Copy link
Collaborator

Hi,

the commit I'm using is the one corresponding to the 5.2.1 release:

commit a322e6bdad4b6675d4597fb2722eea2851ba88cb (HEAD, tag: v5.2.1)

Have you used other APs to test this case?

I've tried with other AP that are only Wi-Fi 4 2.4GHz and it works. The AP that I'm having issues so far is only the Ubiquity that I've mentioned above. This AP has configured a network that has both the band 2.4 and 5GHz and uses the Wi-Fi 6 standard.

I can try to reproduce the issue on another Wi-Fi AP that has Wi-Fi 6 networks, and I will get you back.

@alerighi Thanks for the reply, Also wireless sniffer capture with the Ubiquity AP will be helpful to pin point the issue.

@alerighi
Copy link
Author

Hi @nishanth-radja,

I've reproduced the issue and captured with Wireshark the packets.
wireshark-capture.zip

To see the traffic of the device you can use the filter: wlan.addr == 40:4c:ca:41:83:10

@nishanth-radja
Copy link
Collaborator

@alerighi Thanks for the captures,How far is the STA from the AP and also is the environment very noisy.I see that STA is not able to reply to most of the packets from AP.Also can you disable beam-forming on the AP and disable RTS protection.This will reduce the channel noise. Can you try these and send the capture if the problem persist ?

@alerighi
Copy link
Author

alerighi commented May 2, 2024

Hi,
the AP is near to the STA (approximately 5 meters).

The environment is noisy since we have a lot of Wi-Fi devices, and also there are a lot of Wi-Fi networks and devices from nearby offices (that we don't have control).

I will try what you suggested and get you back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

5 participants