feat: add peer sync for multi-scanner deployments

Enable scanner instances to discover each other and synchronize
device metadata (floors, positions, labels, favorites) automatically.

New features:
- Peer registration API with mutual auto-registration
- Background sync thread with configurable interval
- Timestamp-based conflict resolution (newest wins)
- Config options: peers, sync_interval_seconds, accept_registrations

API endpoints:
- GET/POST /api/peers - list peers, register new peer
- DELETE /api/peers/<id> - remove peer
- GET/POST /api/sync/devices - device sync for peers
- POST /api/sync/trigger - manual sync trigger

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
User
2026-02-01 03:19:04 +01:00
parent bf455f074b
commit fa5178a5be
5 changed files with 1030 additions and 74 deletions

View File

@@ -1,70 +1,55 @@
# RF Mapper Configuration
# ========================
# GPS Reference Position
# Set this to your Home Assistant or scanner location
gps:
# Belgium (Brussels area) - Update with your actual coordinates
latitude: 50.8585853
longitude: 4.3978724
# You can get precise coordinates from Home Assistant at:
# http://192.168.129.10:8123/config/zone
# Web Server Settings
latitude: 50.85852913116932
longitude: 4.3976058563598315
web:
host: "0.0.0.0"
host: 0.0.0.0
port: 5000
debug: false
# Scanner Settings
scanner:
# WiFi interface name
wifi_interface: "wlan0"
# Bluetooth scan timeout in seconds
id: ''
name: ''
latitude: null
longitude: null
floor: null
wifi_interface: wlan0
bt_scan_timeout: 10
# Path loss exponent for distance estimation
# 2.0 = free space, 2.5 = light indoor, 3.0-4.0 = walls
path_loss_exponent: 2.5
# Automatically identify Bluetooth devices (queries device services)
auto_identify_bluetooth: true
# Data Storage
wifi_tx_power: -59
bt_tx_power: -72
# Peer sync settings
peers: [] # List of peer scanner URLs (auto-populated via registration)
sync_interval_seconds: 30 # How often to sync with peers (0 = disabled)
accept_registrations: true # Allow other scanners to register with this one
data:
# Directory for scan data (relative to project root or absolute path)
directory: "data"
# Maximum number of scans to keep (0 = unlimited)
directory: data
max_scans: 100
# SQLite Database for Device History
database:
# Enable historical tracking
enabled: true
# Database filename (stored in data directory)
filename: "devices.db"
# Data retention period in days (auto-cleanup older data)
filename: devices.db
retention_days: 30
# Enable automatic daily cleanup
auto_cleanup: true
# Home Assistant Integration (optional)
home_assistant:
enabled: false
url: "http://192.168.129.10:8123"
# Token can be set here or via HA_TOKEN environment variable
# Generate at: http://192.168.129.10:8123/profile -> Long-Lived Access Tokens
token: ""
# Building Configuration (for 3D map view)
building:
# Enable 3D building visualization
enabled: true
# Building name (displayed in UI)
name: "Home"
# Number of floors in the building
url: http://192.168.129.10:8123
token: ''
webhook_scan: rf_mapper_scan
webhook_new_device: rf_mapper_new_device
webhook_device_gone: rf_mapper_device_gone
device_timeout_minutes: 5
profiling:
enabled: false
cpu: true
memory: false
output_dir: data/profiles
sort_by: cumtime
auto_scan:
enabled: false
interval_minutes: 5
location_label: auto_scan
building:
enabled: true
name: Home
floors: 12
# Height of each floor in meters
floor_height_m: 3.0
# Ground floor number (0 in most countries, 1 in US)
ground_floor_number: 0
# Scanner's current floor (devices scanned will be assigned to this floor)
current_floor: 11