Connection to AP in AP mode with WPA2 not working

tomfrance
Posts: 12
Joined: Wed Mar 17, 2021 3:50 pm

Connection to AP in AP mode with WPA2 not working

Postby tomfrance » Wed Mar 24, 2021 11:44 pm

Hi guys!

I have a small issue that I could not figure out myself: Whenever I use mode WIFI_MODE_AP and require the client to use WIFI_AUTH_WPA2_PSK, the client just would not connect, as the authentification seems to fail. Do you have any idea what the reason is? Changing it to WIFI_AUTH_OPEN makes it work again.

Code: Select all

#include <stdio.h>
#include <string.h>
#include "esp_log.h"
#include "esp_wifi.h"
#include "esp_netif.h"
#include "esp_event.h"
#include "nvs_flash.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"


void app_main(void) {

    nvs_flash_init();
    
    ESP_ERROR_CHECK(esp_event_loop_create_default());

    ESP_ERROR_CHECK(esp_netif_init());

    esp_netif_config_t netif_cfg = ESP_NETIF_DEFAULT_WIFI_AP();
    esp_netif_t *netif = esp_netif_new(&netif_cfg);
    assert(netif);

    esp_netif_attach_wifi_ap(netif);
    

    esp_wifi_set_default_wifi_ap_handlers();

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

    wifi_config_t wifi_config = {
        .ap = {
            .ssid = "mytestap",
            .channel = 11,
            .password = "mypass12345",
            .max_connection = 5,
            .authmode = WIFI_AUTH_WPA2_PSK
        }
    };

    ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
    ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &wifi_config));
    ESP_ERROR_CHECK(esp_wifi_start());


}

The respective log is:

Code: Select all

I (41374) wifi:new:<11,2>, old:<11,2>, ap:<11,2>, sta:<255,255>, prof:11
I (41374) wifi:station: 84:c5:a6:84:2c:54 join, AID=1, bgn, 40D
I (43364) wifi:station: 84:c5:a6:84:2c:54 leave, AID = 1, bss_flags is 658530, bss:0x3ffba3a4
I (43364) wifi:new:<11,0>, old:<11,2>, ap:<11,2>, sta:<255,255>, prof:11
In case of succesful connect it is:

Code: Select all

I (147144) wifi:new:<11,2>, old:<11,2>, ap:<11,2>, sta:<255,255>, prof:11
I (147144) wifi:station: 84:c5:a6:84:2c:54 join, AID=1, bgn, 40D
I (147174) esp_netif_lwip: DHCP server assigned IP to a station, IP is: 192.168.4.2
W (148214) wifi:<ba-add>idx:4 (ifx:1, 84:c5:a6:84:2c:54), tid:0, ssn:17, winSize:64
I have tried different clients as well, all the time same behavior...

Thank you!

tomfrance
Posts: 12
Joined: Wed Mar 17, 2021 3:50 pm

Re: Connection to AP in AP mode with WPA2 not working

Postby tomfrance » Thu Mar 25, 2021 9:32 pm

Does anybody have an idea what the issue might be? Do you need further information?

Volvox
Posts: 21
Joined: Sat Mar 18, 2017 7:54 pm

Re: Connection to AP in AP mode with WPA2 not working

Postby Volvox » Thu Oct 07, 2021 12:55 pm

I have the similar issue, still nobody an idea?

Who is online

Users browsing this forum: atx823, MicroController and 182 guests