Add proximity radar visualization and signal history heatmap

Backend:
- Add device_key.py for stable device identification (identity > public MAC > fingerprint)
- Add distance.py with DistanceEstimator class (path-loss formula, EMA smoothing, confidence scoring)
- Add ring_buffer.py for time-windowed RSSI observation storage
- Extend BTDeviceAggregate with proximity_band, estimated_distance_m, distance_confidence, rssi_ema
- Add new API endpoints: /proximity/snapshot, /heatmap/data, /devices/<key>/timeseries
- Update TSCM integration to include new proximity fields

Frontend:
- Add proximity-radar.js: SVG radar with concentric rings, device dots positioned by distance
- Add timeline-heatmap.js: RSSI history grid with time buckets and color-coded signal strength
- Update bluetooth.js to initialize and feed data to new components
- Replace zone counters with radar visualization and zone summary
- Add proximity-viz.css for component styling

Tests:
- Add test_bluetooth_proximity.py with unit tests for device key stability, EMA smoothing,
  distance estimation, band classification, and ring buffer functionality

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Smittix
2026-01-21 19:25:33 +00:00
parent bd7c83b18c
commit 7957176e59
14 changed files with 2870 additions and 27 deletions

View File

@@ -8,12 +8,17 @@ device aggregation, RSSI statistics, and observable heuristics.
from .aggregator import DeviceAggregator
from .capability_check import check_capabilities, quick_adapter_check
from .constants import (
# Range bands
# Range bands (legacy)
RANGE_VERY_CLOSE,
RANGE_CLOSE,
RANGE_NEARBY,
RANGE_FAR,
RANGE_UNKNOWN,
# Proximity bands (new)
PROXIMITY_IMMEDIATE,
PROXIMITY_NEAR,
PROXIMITY_FAR,
PROXIMITY_UNKNOWN,
# Protocols
PROTOCOL_BLE,
PROTOCOL_CLASSIC,
@@ -25,8 +30,11 @@ from .constants import (
ADDRESS_TYPE_RPA,
ADDRESS_TYPE_NRPA,
)
from .device_key import generate_device_key, is_randomized_mac, extract_key_type
from .distance import DistanceEstimator, ProximityBand, get_distance_estimator
from .heuristics import HeuristicsEngine, evaluate_device_heuristics, evaluate_all_devices
from .models import BTDeviceAggregate, BTObservation, ScanStatus, SystemCapabilities
from .ring_buffer import RingBuffer, get_ring_buffer, reset_ring_buffer
from .scanner import BluetoothScanner, get_bluetooth_scanner, reset_bluetooth_scanner
__all__ = [
@@ -44,6 +52,21 @@ __all__ = [
# Aggregator
'DeviceAggregator',
# Device key generation
'generate_device_key',
'is_randomized_mac',
'extract_key_type',
# Distance estimation
'DistanceEstimator',
'ProximityBand',
'get_distance_estimator',
# Ring buffer
'RingBuffer',
'get_ring_buffer',
'reset_ring_buffer',
# Heuristics
'HeuristicsEngine',
'evaluate_device_heuristics',
@@ -53,15 +76,25 @@ __all__ = [
'check_capabilities',
'quick_adapter_check',
# Constants
# Constants - Range bands (legacy)
'RANGE_VERY_CLOSE',
'RANGE_CLOSE',
'RANGE_NEARBY',
'RANGE_FAR',
'RANGE_UNKNOWN',
# Constants - Proximity bands (new)
'PROXIMITY_IMMEDIATE',
'PROXIMITY_NEAR',
'PROXIMITY_FAR',
'PROXIMITY_UNKNOWN',
# Constants - Protocols
'PROTOCOL_BLE',
'PROTOCOL_CLASSIC',
'PROTOCOL_AUTO',
# Constants - Address types
'ADDRESS_TYPE_PUBLIC',
'ADDRESS_TYPE_RANDOM',
'ADDRESS_TYPE_RANDOM_STATIC',