how to set eth static ip
Posted: Thu Sep 06, 2018 8:29 am
hi all
I can use phy8720, run example of ESP, and get IP through DHCP.
But when I set up static IP, Ping is blocked.
my code
I can use phy8720, run example of ESP, and get IP through DHCP.
But when I set up static IP, Ping is blocked.
my code
Code: Select all
esp_err_t err;
tcpip_adapter_init();
esp_event_loop_init(eth_event_handler, NULL);
eth_config_t config = DEFAULT_ETHERNET_PHY_CONFIG;
config.phy_addr = CONFIG_PHY_ADDRESS;
config.gpio_config = eth_gpio_config_rmii;
config.tcpip_input = tcpip_adapter_eth_input;
config.clock_mode = CONFIG_PHY_CLOCK_MODE;
#ifdef CONFIG_PHY_USE_POWER_PIN
/* Replace the default 'power enable' function with an example-specific one
that toggles a power GPIO. */
printf("########%s()-%d\n",__FUNCTION__,__LINE__);
config.phy_power_enable = phy_device_power_enable_via_gpio;
#endif
tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_ETH);
tcpip_adapter_ip_info_t info;
memset(&info, 0, sizeof(info));
IP4_ADDR(&info.ip, 192, 168, 31, 188);
IP4_ADDR(&info.gw, 192, 168, 31, 1);
IP4_ADDR(&info.netmask, 255, 255, 255, 0);
tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_ETH, &info);
esp_eth_init(&config);
esp_eth_enable();