Read each device in a background thread

A failed JBD read retried forever inside a client request and blocked every other device and client. The server now starts one polling thread for each device, and a request returns the last snapshot. Only the first request after startup waits, until each device completes one read attempt.

One lock makes sure that only one Bluetooth collection runs at a time. A serial BMS retries a failed read after 1 second and keeps its last snapshot for 30 seconds. An error in a collection does not end the polling of that device.
This commit is contained in:
tim
2026-10-10 09:03:34 +02:00
parent d86d59c0f7
commit 953f8a6482
4 changed files with 175 additions and 45 deletions
+6 -2
View File
@@ -94,8 +94,12 @@ Omit `--ups` for all devices. Add `--ups river2` to select one. `--ups all` mean
device named `all`, not all devices. To include a serial BMS, add a server argument
such as `-d network:/dev/ttyUSB0`.
The server caches Bluetooth data for 60 seconds. Failed reads wait 60 seconds
before retrying. Unavailable devices are omitted from the response.
The server reads each device in its own background thread, so a slow or offline
device does not delay the other devices or the clients. It reads one Bluetooth
device at a time and waits 60 seconds after each Bluetooth read, including a
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.
#### Diagnostics