Answer each client in its own thread

The server handled one client at a time, so a client that connected and sent nothing blocked every other client. The request handling is now in handle_client, and the main loop starts one thread for each connection.

The server closes a connection that stays silent for 5 seconds, so its thread ends.
This commit is contained in:
tim
2026-10-10 10:59:34 +02:00
parent 6ee9bbaca8
commit f17d1d82c2
3 changed files with 163 additions and 154 deletions
+3
View File
@@ -101,6 +101,9 @@ failed one. It reads a serial BMS every 5 seconds and retries a failed serial
read after 1 second. Unavailable devices are omitted from the response. Only the
first request after startup waits, until each device completes one read attempt.
The server answers each client in its own thread, so a slow client does not
delay the other clients. It closes a connection that stays silent for 5 seconds.
Each Bluetooth read listens for 10 seconds. If a required report is still
missing, the read continues until the report arrives, for at most 30 seconds in
total. A read that reaches this limit returns a partial snapshot. Its