collector: survive bluetoothd hangs and restarts

- every BlueZ call runs off the asyncio thread with a timeout; if bluetoothd
  stays unresponsive for 30 s the collector restarts bluetooth.service and
  exits for a clean re-registration
- Type=notify + WatchdogSec for buttontask-collector, never give up restarting
- bluetooth.service drop-in: Restart=always (BlueZ 5.55 crashes on assert/SEGV),
  installed by device-install.sh and OTA (bt-update)
- bt-service: bluez-restart action for the collector

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-10 07:10:02 +00:00
co-authored by Claude Opus 5.5
parent 588c2e0135
commit 115879ab67
10 changed files with 265 additions and 89 deletions
+9
View File
@@ -10,6 +10,15 @@ TICK_INTERVAL_S = 0.5 # connect poll + flush cadence
ADV_DEBOUNCE_S = 1.0
UI_LOG_LIMIT = 200
# BlueZ health. Every BlueZ call gets a timeout; if bluetoothd keeps failing
# for BLUEZ_HANG_S, the collector restarts bluetooth.service and exits so
# systemd starts it again with a clean registration.
BLUEZ_CALL_TIMEOUT_S = 8.0 # wrapper timeout around one blocking/async BlueZ call
BLUEZ_START_TIMEOUT_S = 30.0 # GATT server start
BLUEZ_HANG_S = 30.0
BLUEZ_OWNER_CHECK_S = 2.0
BT_SERVICE_HELPER = "/opt/buttontask/scripts/bt-service"
SERVICE_UUID = "0000a000-0000-1000-8000-00805f9b34fb"
CHAR_REPORT_UUID = "0000a001-0000-1000-8000-00805f9b34fb"
CHAR_INTERVAL_UUID = "0000a002-0000-1000-8000-00805f9b34fb"