lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] how lwip know internet cable is unplug


From: Stephane Lesage
Subject: Re: [lwip-users] how lwip know internet cable is unplug
Date: Fri, 2 Sep 2011 10:55:17 +0200

> When unplug internet cable, how lwip deal it ? I want to show message
> to user in LCD to notice user !

Hi,
Here's what I do (NOSYS=0)

In my PHY driver init:
bfphy_msg = tcpip_callbackmsg_new(bfphy_interrupt_callback, netif);

In the interrupt:
tcpip_trycallback(bfphy_msg);

In the callback, executing in the tcpip_thread context:

void bfphy_interrupt_callback(void* ctx)
{
        struct netif* netif = (struct netif*) ctx;

        Read PHY registers (simple function with mutex protection in my
case)
        Set Full-duplex, RMII 10/100 parameters, etc...

        // Link state
        if (stat & PHY_MODESTAT_AUTONEG_COMPLETE)
netif_set_link_up(netif);
        else
netif_set_link_down(netif);
}

Now you can either:
- use the netif callbacks to get the information
- regularly poll with netif_is_link_up(netif);







reply via email to

[Prev in Thread] Current Thread [Next in Thread]