设置方法:使用例程中protocol_examples_common共用联网组件
设置方法如下:
在上述组件connect.c文件的
Code: Select all
static esp_netif_t *eth_start(void)
Code: Select all
ESP_ERROR_CHECK(esp_event_handler_register(ETH_EVENT, ETHERNET_EVENT_CONNECTED, &on_eth_ipv4_event, netif));
Code: Select all
static void on_eth_ipv4_event(void *esp_netif, esp_event_base_t event_base,
int32_t event_id, void *event_data)
{
static int set_up= 0 ;
switch (event_id) {
case ETHERNET_EVENT_CONNECTED:
if(set_up == 0)
{
set_up= 1;
tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_ETH);
tcpip_adapter_ip_info_t eth;
eth.ip.addr = ipaddr_addr("10.10.10.172");
eth.netmask.addr = ipaddr_addr("255.255.255.0");
eth.gw.addr=ipaddr_addr("10.10.10.1");
tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_ETH, ð);
}
break;
default:
break;
}
}