Skip to content

STM32F103 W5500 TCP Server

STM32F103 W5500 TCP Server

mark

Published February 28, 2023

Original author: donglicaiju76152 · ChinaOriginal source (new tab)

STM32F103 W5500 TCP Server

Project description

History: Use STM32F4+LWIP before, but BOM cost too high and not user friendly for LWIP. Finally choose W5500.

3 TCP Client Socket setting:

STM32F103 W5500 TCP Server
STM32F103 W5500 TCP Server
STM32F103 W5500 TCP Server

Problem:

Three TCP Client can be connected successful when testing. However, during the long-term test of the device, it is found that the connection between the client and the server is often disconnected. Once it is disconnected, some clients can connect, and some clients can no longer connect. The only solution is to restart the device.

The client has a reconnection mechanism, which periodically sends heartbeat packets to the server, and then reconnects to the server after a timeout. There is no problem with the whole mechanism, but the problem is that it still cannot connect to the server.

 

Solution

First, use the network debugging assistant to simulate the client, and run it for a long time to see if it will be broken, and it has not been broken. Capture packets through wireshark and find that there is no keepalive heartbeat packet.

 

•Add spare socket:

If there are three clients, then open six clients. Each client has one for normal use and one for backup.

•Heartbeat processing

The automatic sending of heartbeats is changed to manual sending.

•Increase delay

The information packages on the official website are all demo programs based on bare metal, and this project is multi-threaded, so it needs to be modified to delay in the waiting place.

STM32F103 W5500 TCP Server

Remove auto send Keep Alive packet

STM32F103 W5500 TCP Server

Add a spare socket. The standby socket is always in the listen state.
                       STM32F103 W5500 TCP Server

Manually send keepalive heartbeat packets every 10s.

Comments

Similar projects you might like

Comments