how to disconnect a connected wifi client with esp into softAP mode

stbnrivas
Posts: 1
Joined: Tue Oct 06, 2020 2:56 pm

how to disconnect a connected wifi client with esp into softAP mode

Postby stbnrivas » Wed Jan 12, 2022 9:40 am

Hi there, I'm using esp32 as softAP (software Access Point) all work right with the event handler but I need disconnect previous existing wifi clients when new clients connects.

Code: Select all

static void wifi_event_handler(void* arg, esp_event_base_t event_base,
                                    int32_t event_id, void* event_data)
{
    if (event_id == WIFI_EVENT_AP_STACONNECTED) {
        wifi_event_ap_staconnected_t* event = (wifi_event_ap_staconnected_t*) event_data;
        ESP_LOGI(TAG, "station "MACSTR" join, AID=%d", MAC2STR(event->mac), event->aid);
        snprintf(mac_connected_client, 18, "%02X:%02X:%02X:%02X:%02X:%02X", event->mac[0], event->mac[1], event->mac[2], event->mac[3], event->mac[4], event->mac[5] );

    } else if (event_id == WIFI_EVENT_AP_STADISCONNECTED) {
        wifi_event_ap_stadisconnected_t* event = (wifi_event_ap_stadisconnected_t*) event_data;
        ESP_LOGI(TAG, "station "MACSTR" leave, AID=%d", MAC2STR(event->mac), event->aid);
        snprintf(mac_connected_client, 18, "XX:XX:XX:XX:XX:XX");

    }
}

from now I'm using a wifi_config_t for set max connections to 1 but it is not enough, because the client keep connect avoid new connection.

Code: Select all

 
 wifi_config_t wifi_config = {
        .ap = {
            .ssid = EXAMPLE_ESP_WIFI_SSID,
            .ssid_len = strlen(EXAMPLE_ESP_WIFI_SSID),
            .channel = EXAMPLE_ESP_WIFI_CHANNEL,
            .password = "",
            // .password = EXAMPLE_ESP_WIFI_PASS,
            .max_connection = 1,                                                         <<<================= FORCE MAX CONNECTION
            // .max_connection = EXAMPLE_MAX_STA_CONN,
            .authmode = WIFI_AUTH_OPEN
            // .authmode = WIFI_AUTH_WPA_WPA2_PSK
        },
    };


I think that could be interested for an implementation of MAC Addrress filtering too, but I can't find a function into ESP-IDF API to disconnect WIFI clients already connected.


any advices is welcome, thanks in advanced.

YusufG
Posts: 1
Joined: Thu Mar 14, 2024 4:02 pm

Re: how to disconnect a connected wifi client with esp into softAP mode

Postby YusufG » Thu Mar 14, 2024 4:05 pm

Hello,

Any news about MAC filtering or disconnecting a station from SoftAp ?

btohaw
Posts: 1
Joined: Fri Jul 12, 2024 6:39 am

Re: how to disconnect a connected wifi client with esp into softAP mode

Postby btohaw » Fri Jul 12, 2024 6:49 am

Hi, not sure if that solves your problem, but the softAP keeps the connection with stations although they are inactive for 300 seconds (default). You can use the command

esp_wifi_set_inactive_time(wifi_interface_t ifx, uint16_t sec)
with ifx = WIFI_IF_AP
and sec = 10

to force a deauthentification on all stations that are inactive for more that 10 seconds.

Who is online

Users browsing this forum: SegmentationFault and 95 guests