cancel
Showing results for 
Search instead for 
Did you mean: 

stm32 lwip dhcp

yang hong
Associate II

I am using nucleof439 with lwip. I use DHCP to get ip address. Is anyway to detect IP address to be set? I notice there is two thread, "tcpip_thread" and "EthLink", I don't know which one is good for user to get ip address, also struct netif is local variable. it is quite difficult to get it in main.c or freertos.c 

 

 

1 REPLY 1
STea
ST Employee

Hello @yang hong ,

welcome to the ST community .

now passing to your question you can read you IP address in the app_ethernet.c file by accessing the netif structure which you can declare in your main file and it will be used in the tread init phase.

here is the part of netif struct dedicated to the ipv4 

struct netif {
#if !LWIP_SINGLE_NETIF
/** pointer to next in linked list */
struct netif *next;
#endif

#if LWIP_IPV4
/** IP address configuration in network byte order */
ip_addr_t ip_addr;
ip_addr_t netmask;
ip_addr_t gw;

#endif /* LWIP_IPV4 */

you can see a working example in which you can find the exact use case you are trying to get with the Netif Structure declared in the Main.c file on the STM32F429 which is compatible with your nucleoF439 in the following link form GitHub STM32CubeF4/Projects/STM32F429ZI-Nucleo/Applications/LwIP/LwIP_HTTP_Server_Netconn_RTOS at master · STMicroelectronics/STM32CubeF4 · GitHub

also, available on our website STM32CubeF4 - STM32Cube MCU Package for STM32F4 series (HAL, Low-Layer APIs and CMSIS, USB, TCP/IP, File system, RTOS, Graphic - and examples running on ST boards) - STMicroelectronics.

BR

 

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.