{SYSTEM_EVENT_STA_CONNECTED, system_event_sta_connected_handle_default},
{SYSTEM_EVENT_STA_DISCONNECTED, system_event_sta_disconnected_handle_default},
{SYSTEM_EVENT_STA_AUTHMODE_CHANGE, NULL},
+ {SYSTEM_EVENT_STA_GOTIP, NULL},
{SYSTEM_EVENT_AP_START, system_event_ap_start_handle_default},
{SYSTEM_EVENT_AP_STOP, system_event_ap_stop_handle_default},
{SYSTEM_EVENT_AP_STACONNECTED, NULL},
system_event_sta_connected_t *connected;
system_event_sta_disconnected_t *disconnected;
system_event_sta_authmode_change_t *auth_change;
+ system_event_sta_gotip_t *got_ip;
system_event_ap_staconnected_t *staconnected;
system_event_ap_stadisconnected_t *stadisconnected;
system_event_ap_probe_req_rx_t *ap_probereqrecved;
auth_change = &event->event_info.auth_change;
os_printf("SYSTEM_EVENT_STA_AUTHMODE_CHNAGE\nold_mode:%d, new_mode:%d\n", auth_change->old_mode, auth_change->new_mode);
break;
+ case SYSTEM_EVENT_STA_GOTIP:
+ got_ip = &event->event_info.got_ip;
+ os_printf("SYSTEM_EVENT_STA_GOTIP\n");
+ break;
case SYSTEM_EVENT_AP_START:
os_printf("SYSTEM_EVENT_AP_START\n");
break;
SYSTEM_EVENT_STA_CONNECTED, /**< ESP32 station connected to AP */
SYSTEM_EVENT_STA_DISCONNECTED, /**< ESP32 station disconnected to AP */
SYSTEM_EVENT_STA_AUTHMODE_CHANGE, /**< the auth mode of AP connected by ESP32 station changed */
+ SYSTEM_EVENT_STA_GOTIP,
SYSTEM_EVENT_AP_START, /**< ESP32 softap start */
SYSTEM_EVENT_AP_STOP, /**< ESP32 softap start */
SYSTEM_EVENT_AP_STACONNECTED, /**< a station connected to ESP32 soft-AP */
SYSTEM_EVENT_MAX
} system_event_id_t;
+typedef struct {
+ uint32_t addr;
+} esp_ip_addr_t;
+
typedef struct {
uint32_t status; /**< status of scanning APs*/
uint8_t number;
uint8_t new_mode; /**< the new auth mode of AP */
} system_event_sta_authmode_change_t;
+typedef struct {
+ esp_ip_addr_t ip;
+ esp_ip_addr_t netmask;
+ esp_ip_addr_t gw;
+} system_event_sta_gotip_t;
+
typedef struct {
uint8_t mac[6]; /**< MAC address of the station connected to ESP32 soft-AP */
uint8_t aid; /**< the aid that ESP32 soft-AP gives to the station connected to */
system_event_sta_disconnected_t disconnected; /**< ESP32 station disconnected to AP */
system_event_sta_scan_done_t scan_done; /**< ESP32 station scan (APs) done */
system_event_sta_authmode_change_t auth_change; /**< the auth mode of AP ESP32 station connected to changed */
+ system_event_sta_gotip_t got_ip;
system_event_ap_staconnected_t sta_connected; /**< a station connected to ESP32 soft-AP */
system_event_ap_stadisconnected_t sta_disconnected; /**< a station disconnected to ESP32 soft-AP */
system_event_ap_probe_req_rx_t ap_probereqrecved; /**< ESP32 softAP receive probe request packet */
#include "apps/dhcpserver.h"
+#include "esp_event.h"
+
static struct netif *esp_netif[TCPIP_ADAPTER_IF_MAX];
static struct ip_info esp_ip[TCPIP_ADAPTER_IF_MAX];
esp_err_t tcpip_adapter_addr_change_cb(struct netif *netif)
{
tcpip_adapter_if_t tcpip_if;
+ system_event_t evt;
if (!netif) {
TCPIP_ADAPTER_DEBUG("null netif=%p\n", netif);
ip4_addr_set(&esp_ip[tcpip_if].gw, ip_2_ip4(&netif->gw));
//notify event
+ evt.event_id = SYSTEM_EVENT_STA_GOTIP;
+ memcpy(&evt.event_info.got_ip.ip, &esp_ip[tcpip_if].ip, sizeof(evt.event_info.got_ip.ip));
+ memcpy(&evt.event_info.got_ip.netmask, &esp_ip[tcpip_if].netmask, sizeof(evt.event_info.got_ip.netmask));
+ memcpy(&evt.event_info.got_ip.gw, &esp_ip[tcpip_if].gw, sizeof(evt.event_info.got_ip.gw));
+ esp_event_send(&evt);
+
printf("ip: %s, ", inet_ntoa(esp_ip[tcpip_if].ip));
printf("mask: %s, ", inet_ntoa(esp_ip[tcpip_if].netmask));
printf("gw: %s\n", inet_ntoa(esp_ip[tcpip_if].gw));