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.