I have implement a task to check phy status (similar to what you do),
and also I use netifapi_* functions:
static void PhyStatus_Task( struct netif *netif )
{
phy_speed_t physpeed;
phy_duplex_t phyduplex;
bool linkstatus;
status_t result;
ETHSPDOFF();
while(1)
{
result = ethernetif_GetLinkStatus(netif, &linkstatus);
if(result == kStatus_Success)
{
if(linkstatus == true)
{
result = ethernetif_GetLinkSpeedDuplex(netif,
&physpeed, &phyduplex);
if(result == kStatus_Success)
{
ETHSPD(physpeed);
}
netifapi_netif_set_link_up(netif);
}
else
{
ETHSPDOFF();
netifapi_netif_set_link_down(netif);
}
}
else
{
ETHSPDOFF();
netifapi_netif_set_link_down(netif);
}
vTaskDelay(100);
}
}
unfortunately I have a problem: when netif_set_link_up() is finally
called always return immediately:
void
netif_set_link_up(struct netif *netif)
{
if (!(netif->flags & NETIF_FLAG_LINK_UP)) {
netif->flags |= NETIF_FLAG_LINK_UP;
#if LWIP_DHCP
dhcp_network_changed(netif);
#endif /* LWIP_DHCP */
#if LWIP_AUTOIP
autoip_network_changed(netif);
#endif /* LWIP_AUTOIP */
if (netif->flags & NETIF_FLAG_UP) {
netif_issue_reports(netif,
NETIF_REPORT_TYPE_IPV4|NETIF_REPORT_TYPE_IPV6);
}
NETIF_LINK_CALLBACK(netif);
}
}
first 'if' is always false, and I wonder why
best regads
Max
On 05/07/2017 19:21, Noam Weissman wrote:
Yes Sylvain 😊
I already changed the code according to your comments 😊
Thanks.
------------------------------------------------------------------------
*From:* lwip-users <address@hidden> on
behalf of Sylvain Rochet <address@hidden>
*Sent:* Wednesday, July 5, 2017 8:08 PM
*To:* Mailing list for lwIP users
*Subject:* Re: [lwip-users] how to set the link up
Hi,
On Wed, Jul 05, 2017 at 04:55:24PM +0000, Noam Weissman wrote:
>
> My DHCP task calls dhcp_start and wait for an IP. If there is a
> timeout the task will assign a static default IP. You can do something
> similar.
Erm, should I add that dhcp_start() is not thread safe ?
Sylvain