Commit Graph
5 Commits
Author SHA1 Message Date
tim 82def5737f Select the bmspy-ups device from the configured devices
bmspy-ups selected its device from the devices that had data at startup, and exited with status 0 if the selection failed. One failed first read ended the monitor or made it select the wrong device.

The server has a new DEVICES command that lists the configured names, and client.list_devices calls it. bmspy-ups selects from that list and then waits for the first data of its device. A wrong or missing --device now exits with status 2. The service file does not restart on that status, because a restart cannot correct it.

An older server ends on the unknown DEVICES command, so update the server first.
2026-10-10 09:03:35 +02:00
tim 953f8a6482 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.
2026-10-10 09:03:34 +02:00
tim d86d59c0f7 Stop the server thread at the end of each server test
The server tests left main() in a thread after each test. These threads kept their patches active and delayed the suite. Each test now sends an invalid command, which ends the server loop, and then joins the thread. The suite time drops from about 8.5 seconds to about 2 seconds.

Remove one unused line from a test.
2026-10-10 09:03:34 +02:00
tim 3422742204 Fix server SIGTERM handler signature 2026-10-08 14:08:20 +02:00
tim 897ae5dfb7 Add unit tests 2026-05-02 23:12:29 +02:00