How to change ip address using LWIP on K64

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to change ip address using LWIP on K64

跳至解决方案
3,744 次查看
inorman
Contributor III

Hi, I've managed to incorporate the LWIP stack into our project and can successfully ping etc.. and have now moved on to try and make the ip address as a user setting but I'm have trouble getting this to apply. I've followed the ping example and adding netif_set_down first to the sequence as 

netif_set_down(&fsl_netif0);

printf("ip address set as %d.%d.%d.%d\r\n",configIP_ADDR[0],configIP_ADDR[1],configIP_ADDR[2],configIP_ADDR[3]);

IP4_ADDR(&fsl_netif0_ipaddr, configIP_ADDR[0], configIP_ADDR[1], configIP_ADDR[2], configIP_ADDR[3]);
IP4_ADDR(&fsl_netif0_netmask, configNET_MASK[0], configNET_MASK[1], configNET_MASK[2], configNET_MASK[3]);
IP4_ADDR(&fsl_netif0_gw, configGW_ADDR[0], configGW_ADDR[1], configGW_ADDR[2], configGW_ADDR[3]);


lwip_init();

netif_add(&fsl_netif0, &fsl_netif0_ipaddr, &fsl_netif0_netmask, &fsl_netif0_gw,
&fsl_enet_config0, ethernetif0_init, ethernet_input);

netif_set_default(&fsl_netif0);
netif_set_up(&fsl_netif0);

After setting a new ip address pinging the previous address now fails so it's had some effect but I can't successfully ping the new address.

Any ideas on what steps I'm missing?

Thanks

Ian

标记 (2)
0 项奖励
回复
1 解答
3,589 次查看
inorman
Contributor III

For anyone having this issue I found the answer in the LWIP wiki under the IPv4 section https://lwip.fandom.com/wiki/IPv4 

and use the function netif_set_ipaddr instead of adding the interface again.

Cheers

Ian

在原帖中查看解决方案

1 回复
3,590 次查看
inorman
Contributor III

For anyone having this issue I found the answer in the LWIP wiki under the IPv4 section https://lwip.fandom.com/wiki/IPv4 

and use the function netif_set_ipaddr instead of adding the interface again.

Cheers

Ian