[Top][All Lists]

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

[lwip-users] Handling link-up/down, netif-up/down events in LwIP

From: Krzysztof Wesołowski
Subject: [lwip-users] Handling link-up/down, netif-up/down events in LwIP
Date: Fri, 6 Jul 2012 12:25:35 +0200

Hi there,

I am working on device using LwIP to host simple WebPanel.

I am using STM32F4x with FreeRTOS, and I have started with ST's driver and code - they basically make netif_up and link_up at the beginning, assuming that connection will be succesfully initialized.

However, i would like to "gracefully" close what I can when plug is disconeccted and reestablish connection when link is back.

Currently I am doing it this way:

At the beginning of program i init TCPIP, bring stm32 netif up, and setup link maintenence timer (so code is periodically called from lwip thread).

In maintenence timer code i jump through simple state machine:
1   stm32_lwip_driver_state_power_up,
2   stm32_lwip_driver_state_waiting_for_link_up,
3   stm32_lwip_driver_state_auto_negotiating,
4   stm32_lwip_driver_state_mac_dma_confgured_for_link

At power up if cable is ok states are 1->2->3->4.

Entering state 4 calls netif_link_up.

If cable is not connected we simply stay in state 2 (link is down).

When cable gets disconnected during operation there is transition 4->2, netif_link_down_is called and we poll phy for connection.

So there are following questions:
1. Is such scheme alright, thread safe (i use same thread)?
2. Any errors/problem i might encounter which are worth to know upfront?
3. Should netif stay up for whole program operation or should I call netif_set_down?
4. How listening and/or active connections made with netconn API would react to such event?
5. If i write own, simple etharp_output function to check link state before sending, which return code should be used if netif_link_is_down? Does this error will be simply forwarded to caller? should i 

Any other comments are welcome, device is designed to handle big uptimes, so I must eliminate or memory leak and/or crash risks I can.

Krzysztof Wesołowski,

reply via email to

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