[Answered] Calling tcpip_adapter_get_sta_list() in an event handler for SYSTEM_EVENT_AP_STACONNECTED
Posted: Sun Oct 09, 2016 11:08 pm
My app is registering itself as an access point and when a station connects, it is asking for the station list and then using tcpip_adapter_get_sta_list() to augment the data with the IP address of the connected stations. I seem to see that at that time, the IP address of the connected station is "0". Here is my code fragment:
Is this expected behavior? I can see that being correct ... that when we get an event that a station has connected, it doesn't yet have an allocated IP address.
Code: Select all
struct station_info *stations;
ESP_ERROR_CHECK(esp_wifi_get_station_list(&stations));
struct station_list *infoList;
ESP_ERROR_CHECK(tcpip_adapter_get_sta_list(stations, &infoList));
struct station_list *head = infoList;
while(infoList != NULL) {
printf("mac: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x " IPSTR " %d\n",
infoList->mac[0],infoList->mac[1],infoList->mac[2],
infoList->mac[3],infoList->mac[4],infoList->mac[5],
IP2STR(&(infoList->ip)),
(uint32_t)(infoList->ip.addr));
infoList = STAILQ_NEXT(infoList, next);
}
ESP_ERROR_CHECK(esp_adapter_free_sta_list(head));
ESP_ERROR_CHECK(esp_wifi_free_station_list());