Hi xiangxistu,
thank you for help, this done a trick, and work like charm.
Here is a test code if someone need it:
int dhcpDown(void) {
struct netdev *netdev = RT_NULL;
ip_addr_t dns_addr;
netdev = netdev_get_by_name("e0");
if (netdev == RT_NULL) {
rt_kprintf("bad network interface device name(e0).\n");
}
netdev_dhcp_enabled(netdev, RT_FALSE);
inet_aton("192.168.1.10", &dns_addr);
if (netdev_set_dns_server(netdev, 0, &dns_addr) == RT_EOK) {
rt_kprintf("set network interface device(%s) dns server #%d: %s\n", "e0", 0, "192.168.1.10");
}
inet_aton("192.168.1.251", &dns_addr);
netdev_set_ipaddr(netdev, &dns_addr);
}
int dhcpUp(void) {
struct netdev *netdev = RT_NULL;
netdev = netdev_get_by_name("e0");
if (netdev == RT_NULL) {
rt_kprintf("bad network interface device name(e0).\n");
}
netdev_dhcp_enabled(netdev, RT_TRUE);
}
MSH_CMD_EXPORT(dhcpDown, disable DHCP and set static IP);
MSH_CMD_EXPORT(dhcpUp, enable DHCP);
Thank you again.
Ok, while we are here, I got another one question :)
I'm using CH32V307, and he does not have dedicated pins for network LED's. I try to find out in board files and low level functions to assign and enable this LEDs to have visual representation of network activity. Without RT Thread, I use WCHNET library and there is Ethernet_LED_LINKSET and Ethernet_LED_DATASET and this done a trick. This is lib external functions, but I can not find anything like this in RT.
Any idea how to do that?
THX
Goran
Ask lwip sitch from DHCP to static IP at runtime