esp32/tcpipadapter: correct eth ip got event info
1. Raise SYSTEM_EVENT_ETH_GOT_IP when eth got ip 2. Add default handler for SYSTEM_EVENT_ETH_GOT_IP 3. Minor change about ethernet kconfig
This commit is contained in:
parent
6ff5c32ae5
commit
e04a0d66b8
3 changed files with 21 additions and 4 deletions
|
@ -61,6 +61,7 @@ static esp_err_t system_event_eth_start_handle_default(system_event_t *event);
|
||||||
static esp_err_t system_event_eth_stop_handle_default(system_event_t *event);
|
static esp_err_t system_event_eth_stop_handle_default(system_event_t *event);
|
||||||
static esp_err_t system_event_eth_connected_handle_default(system_event_t *event);
|
static esp_err_t system_event_eth_connected_handle_default(system_event_t *event);
|
||||||
static esp_err_t system_event_eth_disconnected_handle_default(system_event_t *event);
|
static esp_err_t system_event_eth_disconnected_handle_default(system_event_t *event);
|
||||||
|
static esp_err_t system_event_eth_got_ip_default(system_event_t *event);
|
||||||
|
|
||||||
/* Default event handler functions
|
/* Default event handler functions
|
||||||
|
|
||||||
|
@ -124,11 +125,21 @@ esp_err_t system_event_eth_disconnected_handle_default(system_event_t *event)
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static esp_err_t system_event_eth_got_ip_default(system_event_t *event)
|
||||||
|
{
|
||||||
|
ESP_LOGI(TAG, "eth ip: " IPSTR ", mask: " IPSTR ", gw: " IPSTR,
|
||||||
|
IP2STR(&event->event_info.got_ip.ip_info.ip),
|
||||||
|
IP2STR(&event->event_info.got_ip.ip_info.netmask),
|
||||||
|
IP2STR(&event->event_info.got_ip.ip_info.gw));
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static esp_err_t system_event_sta_got_ip_default(system_event_t *event)
|
static esp_err_t system_event_sta_got_ip_default(system_event_t *event)
|
||||||
{
|
{
|
||||||
WIFI_API_CALL_CHECK("esp_wifi_internal_set_sta_ip", esp_wifi_internal_set_sta_ip(), ESP_OK);
|
WIFI_API_CALL_CHECK("esp_wifi_internal_set_sta_ip", esp_wifi_internal_set_sta_ip(), ESP_OK);
|
||||||
|
|
||||||
ESP_LOGI(TAG, "ip: " IPSTR ", mask: " IPSTR ", gw: " IPSTR,
|
ESP_LOGI(TAG, "sta ip: " IPSTR ", mask: " IPSTR ", gw: " IPSTR,
|
||||||
IP2STR(&event->event_info.got_ip.ip_info.ip),
|
IP2STR(&event->event_info.got_ip.ip_info.ip),
|
||||||
IP2STR(&event->event_info.got_ip.ip_info.netmask),
|
IP2STR(&event->event_info.got_ip.ip_info.netmask),
|
||||||
IP2STR(&event->event_info.got_ip.ip_info.gw));
|
IP2STR(&event->event_info.got_ip.ip_info.gw));
|
||||||
|
@ -414,4 +425,5 @@ void esp_event_set_default_eth_handlers()
|
||||||
default_event_handlers[SYSTEM_EVENT_ETH_STOP] = system_event_eth_stop_handle_default;
|
default_event_handlers[SYSTEM_EVENT_ETH_STOP] = system_event_eth_stop_handle_default;
|
||||||
default_event_handlers[SYSTEM_EVENT_ETH_CONNECTED] = system_event_eth_connected_handle_default;
|
default_event_handlers[SYSTEM_EVENT_ETH_CONNECTED] = system_event_eth_connected_handle_default;
|
||||||
default_event_handlers[SYSTEM_EVENT_ETH_DISCONNECTED] = system_event_eth_disconnected_handle_default;
|
default_event_handlers[SYSTEM_EVENT_ETH_DISCONNECTED] = system_event_eth_disconnected_handle_default;
|
||||||
|
default_event_handlers[SYSTEM_EVENT_ETH_GOT_IP] = system_event_eth_got_ip_default;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ config DMA_RX_BUF_NUM
|
||||||
If enable flow ctrl, the num must be above 9 .
|
If enable flow ctrl, the num must be above 9 .
|
||||||
|
|
||||||
config DMA_TX_BUF_NUM
|
config DMA_TX_BUF_NUM
|
||||||
int "Number of DMA RX buffers"
|
int "Number of DMA TX buffers"
|
||||||
range 3 20
|
range 3 20
|
||||||
default 10
|
default 10
|
||||||
help
|
help
|
||||||
|
|
|
@ -756,8 +756,13 @@ static void tcpip_adapter_dhcpc_cb(struct netif *netif)
|
||||||
ip4_addr_set(&ip_info->gw, ip_2_ip4(&netif->gw));
|
ip4_addr_set(&ip_info->gw, ip_2_ip4(&netif->gw));
|
||||||
|
|
||||||
//notify event
|
//notify event
|
||||||
evt.event_id = SYSTEM_EVENT_STA_GOT_IP;
|
if (tcpip_if == TCPIP_ADAPTER_IF_ETH) {
|
||||||
evt.event_info.got_ip.ip_changed = false;
|
evt.event_id = SYSTEM_EVENT_ETH_GOT_IP;
|
||||||
|
evt.event_info.got_ip.ip_changed = true;
|
||||||
|
} else {
|
||||||
|
evt.event_id = SYSTEM_EVENT_STA_GOT_IP;
|
||||||
|
evt.event_info.got_ip.ip_changed = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (memcmp(ip_info, ip_info_old, sizeof(tcpip_adapter_ip_info_t))) {
|
if (memcmp(ip_info, ip_info_old, sizeof(tcpip_adapter_ip_info_t))) {
|
||||||
evt.event_info.got_ip.ip_changed = true;
|
evt.event_info.got_ip.ip_changed = true;
|
||||||
|
|
Loading…
Reference in a new issue