cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 & CubeMX LWIP change IP

YiKai
Associate II

Hi, I use LWIP to establish a connection, We want to change the IP address, how can I update IP?

 tcpip_init( NULL, NULL );
 
  /* IP addresses initialization without DHCP (IPv4) */
  IP4_ADDR(&ipaddr, IP_ADDRESS[0], IP_ADDRESS[1], IP_ADDRESS[2], IP_ADDRESS[3]);
  IP4_ADDR(&netmask, NETMASK_ADDRESS[0], NETMASK_ADDRESS[1] , NETMASK_ADDRESS[2], NETMASK_ADDRESS[3]);
  IP4_ADDR(&gw, GATEWAY_ADDRESS[0], GATEWAY_ADDRESS[1], GATEWAY_ADDRESS[2], GATEWAY_ADDRESS[3]);
 
  /* add the network interface (IPv4/IPv6) with RTOS */
  netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &tcpip_input);
 
  /* Registers the default network interface */
  netif_set_default(&gnetif);
 
  if (netif_is_link_up(&gnetif))
  {
    /* When the netif is fully configured this function must be called */
    netif_set_up(&gnetif);
  }
  else
  {
    /* When the netif link is down this function must be called */
    netif_set_down(&gnetif);
}

I used to remove the link and reconnect, it doesn't work. is there any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
Khouloud ZEMMELI
ST Employee

Hello @YiKai​ 

You need to Disable the LWIP_DHCP then under IP Address settings you can update it.

Please use the latest CubeMX release (6.0.1) because there's an issue related to LWIP in the previous version (5.6.1).

0693W000004Jc0DQAS.png 

Best Regards,

Khouloud

View solution in original post

2 REPLIES 2
Khouloud ZEMMELI
ST Employee

Hello @YiKai​ 

You need to Disable the LWIP_DHCP then under IP Address settings you can update it.

Please use the latest CubeMX release (6.0.1) because there's an issue related to LWIP in the previous version (5.6.1).

0693W000004Jc0DQAS.png 

Best Regards,

Khouloud

YiKai
Associate II

Thanks, I use the latest CubeMX release, it's work.