Page 1 of 1

ESP32 wifi couldn't connect to specific SSID

Posted: Mon Nov 18, 2019 2:00 am
by chadpham75
Hi all,
Could you guys please help me to point out how/where can I download the wifi stack code to try to debug my problem of the wifi couldn't reconnect to the same SSID/passkey?
I don't know where to find the dump information like "wifi: add mismatch" in the trace below
W (926900) wifi: add mismatch
I (928220) wifi: new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
I (928220) wifi: state: run -> auth (b0)
I (928220) wifi: state: run -> init (7c0)
I (928220) wifi: new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
I (928230) wifi: new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
I (928230) wifi: new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
I (928240) wifi: state: init -> auth (b0)
I (928250) wifi: state: auth -> assoc (0)
I (928250) wifi: state: assoc -> run (10)
W (928260) wifi: add mismatch
I (934220) wifi: new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
I (934220) wifi: state: run -> auth (b0)
W (934330) wifi: add mismatch
I (935220) wifi: state: run -> init (200)
I (935220) wifi: new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
I (935220) wifi: new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
I (935230) wifi: state: init -> auth (b0)
I (935240) wifi: state: auth -> init (fc0)
I (935240) wifi: new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
W (935250) wifi: tx null, bss is null
I (935370) wifi: new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
I (935370) wifi: state: init -> auth (b0)
I (935370) wifi: state: auth -> init (7c0)
I (935380) wifi: new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
W (935390) wifi: tx null, bss is null
I (935510) wifi: new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
I (935510) wifi: state: init -> auth (b0)
I (935580) wifi: state: auth -> init (7c0)
I (935580) wifi: new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
W (935580) wifi: tx null, bss is null
W (935830) wifi: tx null, bss is null
I (936430) wifi: new:<6,0>, old:<11,0>, ap:<255,255>, sta:<6,0>, prof:1
I (936440) wifi: state: init -> auth (b0)
I (937440) wifi: state: auth -> init (200)
I (937440) wifi: new:<6,0>, old:<6,0>, ap:<255,255>, sta:<6,0>, prof:1
W (937440) wifi: tx null, bss is null
W (937500) wifi: tx null, bss is null
I (938290) wifi: new:<6,0>, old:<6,0>, ap:<255,255>, sta:<6,0>, prof:1
I (938300) wifi: state: init -> auth (b0)
I (939300) wifi: state: auth -> init (200)
I (939300) wifi: new:<6,0>, old:<6,0>, ap:<255,255>, sta:<6,0>, prof:1
Does anyone know where I can find the information for these debug log? It is not in the library folder.
Thank you for your helps.

Re: ESP32 wifi couldn't connect to specific SSID

Posted: Mon Nov 18, 2019 2:50 am
by WiFive
Unfortunately it is closed source and undocumented. What version and commit of esp-idf? What is the structure of your WiFi network?

Re: ESP32 wifi couldn't connect to specific SSID

Posted: Mon Nov 18, 2019 6:05 am
by chadpham75
WiFive,
I am using V4.0-beta1.
We are using the default library

Code: Select all

#define WIFI_INIT_CONFIG_DEFAULT() { \
    .event_handler = &esp_event_send, \
    .osi_funcs = &g_wifi_osi_funcs, \
    .wpa_crypto_funcs = g_wifi_default_wpa_crypto_funcs, \
    .static_rx_buf_num = CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM,\
    .dynamic_rx_buf_num = CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM,\
    .tx_buf_type = CONFIG_ESP32_WIFI_TX_BUFFER_TYPE,\
    .static_tx_buf_num = WIFI_STATIC_TX_BUFFER_NUM,\
    .dynamic_tx_buf_num = WIFI_DYNAMIC_TX_BUFFER_NUM,\
    .csi_enable = WIFI_CSI_ENABLED,\
    .ampdu_rx_enable = WIFI_AMPDU_RX_ENABLED,\
    .ampdu_tx_enable = WIFI_AMPDU_TX_ENABLED,\
    .nvs_enable = WIFI_NVS_ENABLED,\
    .nano_enable = WIFI_NANO_FORMAT_ENABLED,\
    .tx_ba_win = WIFI_DEFAULT_TX_BA_WIN,\
    .rx_ba_win = WIFI_DEFAULT_RX_BA_WIN,\
    .wifi_task_core_id = WIFI_TASK_CORE_ID,\
    .beacon_max_len = WIFI_SOFTAP_BEACON_MAX_LEN, \
    .mgmt_sbuf_num = WIFI_MGMT_SBUF_NUM, \
    .magic = WIFI_INIT_CONFIG_MAGIC\
};
At the initialization

Code: Select all

 {
        tcpip_adapter_init();
         wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
        ESP_ERROR_CHECK( esp_wifi_init(&cfg) );

        ESP_ERROR_CHECK( esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL) );
        ESP_ERROR_CHECK( esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL) );

        ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
        ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_NULL) );
        ESP_ERROR_CHECK( esp_wifi_start() );
    }
When I received the SSID and Passkey input, I will call the api to disconnect if previously successfully connect; otherwise, I will call the api to connect right away

Code: Select all

{
    int bits = xEventGroupWaitBits(wifi_event_group, WIFI_CONNECTED_BIT, 0, 1, 0);

    if (bits & WIFI_CONNECTED_BIT) {
        reconnect = false;
        xEventGroupClearBits(wifi_event_group, WIFI_CONNECTED_BIT);
        ESP_ERROR_CHECK( esp_wifi_disconnect() );
        xEventGroupWaitBits(wifi_event_group, WIFI_DISCONNECTED_BIT, 0, 1, portTICK_RATE_MS);
    }
 
    ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
    ESP_ERROR_CHECK( esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) );

    if (ssid && strlen(ssid))
    {
        reconnect = true;
        ESP_ERROR_CHECK( esp_wifi_connect() );
        xEventGroupWaitBits(wifi_event_group, WIFI_CONNECTED_BIT, 0, 1, 5000/portTICK_RATE_MS);
    }

}
I understood it is close code and no document, but can you suggest for me to have at least the debug dump or something that cause the problem?

What is exactly "add mismatch"? Is it because we tried to connect to the same SSID but with different password, or different SSIDs but the memory still has the same SSID?
Thank you so much for your helps.

Re: ESP32 wifi couldn't connect to specific SSID

Posted: Mon Nov 18, 2019 7:12 am
by WiFive
What is the structure of your WiFi network?
What I mean is how many access points, repeaters, mesh do you have and are they on different channels?

Re: ESP32 wifi couldn't connect to specific SSID

Posted: Mon Nov 18, 2019 8:32 am
by chadpham75
WiFive,
For my developing set up, I only have one AP, one esp32, one app to send the SSID and passkey, over and over again to test the system reliable.
Could you please suggest where/what I can insert the debug trace to get more information to provide to you?

Re: ESP32 wifi couldn't connect to specific SSID

Posted: Mon Nov 18, 2019 6:43 pm
by Ritesh
chadpham75 wrote:
Mon Nov 18, 2019 8:32 am
WiFive,
For my developing set up, I only have one AP, one esp32, one app to send the SSID and passkey, over and over again to test the system reliable.
Could you please suggest where/what I can insert the debug trace to get more information to provide to you?
Hello,

What type of testing you are doing with AP, ESP32 and Application? Can you please elaborate it with little bit more information?

Also, Would you please try to create same Access Point into another mobile to see like issue is into router or something like that? Or check to connect mobile into same router in which ESP32 device is try it to connect and facing same issue or not.

Device is working with PCB or external antenna?

Hope we can get root cause analysis of current issue.