HI Ake and Simon: I set callback function as following, but have to call netif_set_link_up/down to trigger the callback function. Once cable is unplugged / plugged, the netif_set_link_down/up should be called by one times. I don’t know how to do this… I can use the ETH_GetNetifUporDown function to get the Ethernet link status (not lwIP link status), but where to put it ?
Would you help me static uint32_t ETH_GetNetifUporDown (void) { return (ETH_ReadPHYRegister(PHY_ADDRESS, PHY_BSR) & PHY_Linked_Status) ? 1:0; } ------------------------------------------------------------------------------------------------------------------------ void lwip_link_callback(struct netif *netif ) { if (netif_is_link_up(netif)) { printf ("link status go to up \r\n"); dhcp_start(netif); netif_set_up(netif); } else { printf ("link status go to down \r\n"); dhcp_stop(netif); netif_set_down(netif); } } Set the call back function in lnit_lwip() … netif_add(&netif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, &tcpip_input); netif_set_default(&netif); netif_set_link_callback(&netif, lwip_link_callback); … ------------------------------------------------------------------------------------------------------------------------ Vincent Cui Sr.Firmware Engineer Mobile: +8613482482211 Tel: +86 21 34612525x6104 Fax: +86 21 34619770 E-Mail: vincent....@enlogic.com<mailto:vincent....@enlogic.com> Shanghai EnLogic Electric Technology Co., Ltd. Address: 1104-1106, Building A, No.391, Guiping Road, Xuhui District, Shanghai, 200233 http://www.enlogic.com From: lwip-users-bounces+vincent.cui=enlogic....@nongnu.org [mailto:lwip-users-bounces+vincent.cui=enlogic....@nongnu.org] On Behalf Of ake.forsl...@nibe.se Sent: 2011年9月2日 14:50 To: Mailing list for lwIP users Subject: Re: [lwip-users] how lwip know internet cable is unplug Hi! I think that is something you define in your ethernet driver. My approach is to send a signal to a separate task to handle the cable-plug/unplug events. In the task I currently disable dhcp (if active) on cable-unplug signal and reenable it on cable-connect. it might be good to set an auto-ip when unplugged as well, but I'm not sure. Maybe it should be handled with the netif_set_up/down-functions instead, I'm still experimenting... /Åke ----------------------------- Åke Forslund 0433-273296 NIBE AB Box 14 S-285 21 Markaryd Tel +46-(0)433-273296 From: vincent cui <vincent....@enlogic.com> To: Mailing list for lwIP users <lwip-users@nongnu.org> Date: 2011-09-02 07:27 Subject: [lwip-users] how lwip know internet cable is unplug Sent by: lwip-users-bounces+ake.forslund=nibe...@nongnu.org ________________________________ Hi; When unplug internet cable, how lwip deal it ? I want to show message to user in LCD to notice user ! 锘?Vincent Cui Sr.Firmware Engineer Mobile: +8613482482211 Tel: +86 21 34612525x6104 Fax: +86 21 34619770 E-Mail: vincent....@enlogic.com Shanghai EnLogic Electric Technology Co., Ltd. Address: 1104-1106, Building A, No.391, Guiping Road, Xuhui District, Shanghai, 200233 http://www.enlogic.com<http://www.enlogic.com/> -----Original Message----- From: lwip-users-bounces+vincent.cui=enlogic....@nongnu.org [mailto:lwip-users-bounces+vincent.cui=enlogic....@nongnu.org] On Behalf Of Kieran Mansley Sent: 2011年9月2日 3:22 To: Mailing list for lwIP users Subject: Re: [lwip-users] FreeRTOS / lwip multiple connections On 31 Aug 2011, at 01:18, vincent cui wrote: > K: > You mean I need make accept socket to be non-blocking , right ? No, I'm not sure why you need any of your sockets to be non-blocking. Kieran _______________________________________________ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users _______________________________________________ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users
_______________________________________________ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users