Disconnect from Bluetooth devices before the server stops
The polling threads are daemon threads, so a stop ended the server in the middle of a Bluetooth read. The read got no disconnect, and the adapter kept an open connection or a scan in progress. The server now sets the stop event at exit, closes its socket, and waits at most 20 seconds for the polling threads. A Bluetooth read that sees the stop event cancels its current step, disconnects, and returns. A read that waits for the adapter does not connect after a stop.
This commit is contained in:
@@ -104,6 +104,11 @@ 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.
|
||||
|
||||
The server holds a Bluetooth connection only during a read, and disconnects
|
||||
after each one. When the server stops, it ends a read in progress and
|
||||
disconnects from that device before it exits. It waits at most 20 seconds for
|
||||
the disconnect.
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user