i have registered the following wifi event handler:
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);
} 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);
} else if ( event_id == IP_EVENT_STA_GOT_IP) {
ESP_LOGI(TAG, "IP_EVENT_STA_GOT_IP");
//xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
}else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED)
{
ESP_LOGI(TAG, "WIFI_EVENT_STA_DISCONNECTED");
xEventGroupSetBits(wifi_event_group, WIFI_FAIL_BIT);
}
else if (event_id == WIFI_EVENT_STA_CONNECTED )
{
ESP_LOGI(TAG, "WIFI_EVENT_STA_CONNECTED");
xEventGroupSetBits(wifi_event_group, WIFI_CONNECTED_BIT);
}
}
Code: Select all
I (99078) example: WIFI_MODE_STA connected
I (99788) esp_netif_handlers: sta ip: 192.168.1.111, mask: 255.255.255.0, gw: 192.168.1.254