mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 14:50:00 -07:00
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:
@@ -11,8 +11,13 @@ from typing import Optional
|
||||
from .constants import (
|
||||
MANUFACTURER_NAMES,
|
||||
ADDRESS_TYPE_PUBLIC,
|
||||
ADDRESS_TYPE_RANDOM,
|
||||
ADDRESS_TYPE_RANDOM_STATIC,
|
||||
ADDRESS_TYPE_RPA,
|
||||
ADDRESS_TYPE_NRPA,
|
||||
RANGE_UNKNOWN,
|
||||
PROTOCOL_BLE,
|
||||
PROXIMITY_UNKNOWN,
|
||||
)
|
||||
|
||||
|
||||
@@ -100,10 +105,21 @@ class BTDeviceAggregate:
|
||||
rssi_variance: Optional[float] = None
|
||||
rssi_confidence: float = 0.0 # 0.0-1.0
|
||||
|
||||
# Range band (very_close/close/nearby/far/unknown)
|
||||
# Range band (very_close/close/nearby/far/unknown) - legacy
|
||||
range_band: str = RANGE_UNKNOWN
|
||||
range_confidence: float = 0.0
|
||||
|
||||
# Proximity band (new system: immediate/near/far/unknown)
|
||||
device_key: Optional[str] = None
|
||||
proximity_band: str = PROXIMITY_UNKNOWN
|
||||
estimated_distance_m: Optional[float] = None
|
||||
distance_confidence: float = 0.0
|
||||
rssi_ema: Optional[float] = None
|
||||
rssi_60s_min: Optional[int] = None
|
||||
rssi_60s_max: Optional[int] = None
|
||||
is_randomized_mac: bool = False
|
||||
threat_tags: list[str] = field(default_factory=list)
|
||||
|
||||
# Device info (merged from observations)
|
||||
name: Optional[str] = None
|
||||
manufacturer_id: Optional[int] = None
|
||||
@@ -193,10 +209,21 @@ class BTDeviceAggregate:
|
||||
'rssi_confidence': round(self.rssi_confidence, 2),
|
||||
'rssi_history': self.get_rssi_history(),
|
||||
|
||||
# Range
|
||||
# Range (legacy)
|
||||
'range_band': self.range_band,
|
||||
'range_confidence': round(self.range_confidence, 2),
|
||||
|
||||
# Proximity (new system)
|
||||
'device_key': self.device_key,
|
||||
'proximity_band': self.proximity_band,
|
||||
'estimated_distance_m': round(self.estimated_distance_m, 2) if self.estimated_distance_m else None,
|
||||
'distance_confidence': round(self.distance_confidence, 2),
|
||||
'rssi_ema': round(self.rssi_ema, 1) if self.rssi_ema else None,
|
||||
'rssi_60s_min': self.rssi_60s_min,
|
||||
'rssi_60s_max': self.rssi_60s_max,
|
||||
'is_randomized_mac': self.is_randomized_mac,
|
||||
'threat_tags': self.threat_tags,
|
||||
|
||||
# Device info
|
||||
'name': self.name,
|
||||
'manufacturer_id': self.manufacturer_id,
|
||||
@@ -231,6 +258,7 @@ class BTDeviceAggregate:
|
||||
"""Compact dictionary for list views."""
|
||||
return {
|
||||
'device_id': self.device_id,
|
||||
'device_key': self.device_key,
|
||||
'address': self.address,
|
||||
'address_type': self.address_type,
|
||||
'protocol': self.protocol,
|
||||
@@ -238,7 +266,12 @@ class BTDeviceAggregate:
|
||||
'manufacturer_name': self.manufacturer_name,
|
||||
'rssi_current': self.rssi_current,
|
||||
'rssi_median': round(self.rssi_median, 1) if self.rssi_median else None,
|
||||
'rssi_ema': round(self.rssi_ema, 1) if self.rssi_ema else None,
|
||||
'range_band': self.range_band,
|
||||
'proximity_band': self.proximity_band,
|
||||
'estimated_distance_m': round(self.estimated_distance_m, 2) if self.estimated_distance_m else None,
|
||||
'distance_confidence': round(self.distance_confidence, 2),
|
||||
'is_randomized_mac': self.is_randomized_mac,
|
||||
'last_seen': self.last_seen.isoformat(),
|
||||
'age_seconds': self.age_seconds,
|
||||
'seen_count': self.seen_count,
|
||||
|
||||
Reference in New Issue
Block a user