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. Reagrds, Krzysztof Wesołowski,
_______________________________________________ lwip-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/lwip-users
