diff --git a/components/esp8266/include/esp_event.h b/components/esp8266/include/esp_event.h index c3d8e75a..6c496e4a 100644 --- a/components/esp8266/include/esp_event.h +++ b/components/esp8266/include/esp_event.h @@ -129,6 +129,11 @@ typedef struct { uint8_t mac[6]; /**< MAC address of the station which send probe request */ } system_event_ap_probe_req_rx_t; +/** Event structure for IP_EVENT_AP_STAIPASSIGNED event */ +typedef struct { + ip4_addr_t ip; /*!< IP address which was assigned to the station */ +} system_event_ap_staipassigned_t; + typedef union { system_event_sta_connected_t connected; /**< ESP8266 station connected to AP */ system_event_sta_disconnected_t disconnected; /**< ESP8266 station disconnected to AP */ @@ -140,6 +145,7 @@ typedef union { system_event_ap_staconnected_t sta_connected; /**< a station connected to ESP8266 soft-AP */ system_event_ap_stadisconnected_t sta_disconnected; /**< a station disconnected to ESP8266 soft-AP */ system_event_ap_probe_req_rx_t ap_probereqrecved; /**< ESP8266 soft-AP receive probe request packet */ + system_event_ap_staipassigned_t ap_staipassigned; /**< ESP8266 soft-AP assign an IP to the station*/ system_event_got_ip6_t got_ip6; /**< ESP8266 station or ap or ethernet ipv6 addr state change to preferred */ } system_event_info_t; diff --git a/components/tcpip_adapter/tcpip_adapter_lwip.c b/components/tcpip_adapter/tcpip_adapter_lwip.c index 77d28d99..ff2e6086 100644 --- a/components/tcpip_adapter/tcpip_adapter_lwip.c +++ b/components/tcpip_adapter/tcpip_adapter_lwip.c @@ -93,6 +93,7 @@ static void tcpip_adapter_dhcps_cb(u8_t client_ip[4]) client_ip[0],client_ip[1],client_ip[2],client_ip[3]); system_event_t evt; evt.event_id = SYSTEM_EVENT_AP_STAIPASSIGNED; + memcpy(&evt.event_info.ap_staipassigned.ip, client_ip, sizeof(ip4_addr_t)); esp_event_send(&evt); } diff --git a/examples/wifi/simple_wifi/main/simple_wifi.c b/examples/wifi/simple_wifi/main/simple_wifi.c index 975d393e..e92bd64d 100644 --- a/examples/wifi/simple_wifi/main/simple_wifi.c +++ b/examples/wifi/simple_wifi/main/simple_wifi.c @@ -70,6 +70,10 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) esp_wifi_connect(); xEventGroupClearBits(wifi_event_group, WIFI_CONNECTED_BIT); break; + case SYSTEM_EVENT_AP_STAIPASSIGNED: + ESP_LOGI(TAG, "assigned ip:%s", + ip4addr_ntoa(&event->event_info.ap_staipassigned.ip)); + break; default: break; }