Files
Button/collector/config.py
T
2026-10-16 07:19:06 +03:00

64 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""Collector constants and filesystem paths."""
import os
from pathlib import Path
N = 4
POLL_PERIOD_S = 30
STALE_PERIODS = 3 # k: silence for k*period → stale; another k → lost
TICK_INTERVAL_S = 5.0
ADV_INTERVAL_MS_MIN = 100
ADV_INTERVAL_MS_MAX = 300
ADV_DEBOUNCE_S = 1.0
UI_LOG_LIMIT = 200
SERVICE_UUID = "0000a000-0000-1000-8000-00805f9b34fb"
CHAR_REPORT_UUID = "0000a001-0000-1000-8000-00805f9b34fb"
CHAR_SLOT_UUID = "0000a011-0000-1000-8000-00805f9b34fb"
# 16-bit forms for advertising
SERVICE_UUID_16 = 0xA000
COMPANY_ID = 0xFFFF # placeholder manufacturer id
ADV_VERSION = 1
LOCAL_NAME = "BTCollector"
def install_root() -> Path:
env = os.environ.get("BUTTONTASK_ROOT")
if env:
return Path(env)
return Path("/opt/buttontask")
def config_dir() -> Path:
p = install_root() / "config"
p.mkdir(parents=True, exist_ok=True)
return p
def run_dir() -> Path:
p = install_root() / "run"
p.mkdir(parents=True, exist_ok=True)
return p
def registry_path() -> Path:
return config_dir() / "sensors-registry.json"
def status_path() -> Path:
return run_dir() / "sensors-status.json"
def ui_log_path() -> Path:
return run_dir() / "sensors-ui.log"
def cmd_path() -> Path:
return run_dir() / "sensors-cmd"
def collector_log_path() -> Path:
return run_dir() / "collector.log"