2024-07-02 08:28 AM
/* add the network interface (IPv4/IPv6) with RTOS */
netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, &tcpip_input);
while(1){
/* 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);
break;
}
else
{
/* When the netif link is down this function must be called */
netif_set_down(&gnetif);
}
/* Set the link callback function, this function is called on change of link status*/
netif_set_link_callback(&gnetif, ethernet_link_status_updated);
}
I am trying to get link up in the if statement but in first time run i usually get set down. To fix that i included all to a while statement but it gets stuck in else statement. I am using stm32h735.
Solved! Go to Solution.
2024-07-02 09:31 AM
The link up/down APIs in the examples are not used correctly (sorry don't remember details). For a start, ensure that the cable is connected and wait in while loop before line 7, until the PHY reports link up. Something like:
while (!netif_is_link_up(&gnetif)) {}
netif_set_up(&gnetif);
Later look up the original LwIP examples on their website and implement dynamic changes in link state.
2024-07-02 09:31 AM
The link up/down APIs in the examples are not used correctly (sorry don't remember details). For a start, ensure that the cable is connected and wait in while loop before line 7, until the PHY reports link up. Something like:
while (!netif_is_link_up(&gnetif)) {}
netif_set_up(&gnetif);
Later look up the original LwIP examples on their website and implement dynamic changes in link state.
2024-07-03 12:25 AM
Thanks a lot deleting while 1 loop and adding what you said is solved the issue.
2024-07-10 07:21 AM
Thanks so much for your answer. I do get connected more frequently than before but Sometimes I just have to restart the power to get connected. Is there any other step that you recommend for better connectivity for ethernet part?