feat: wire BLE scan broadcasts to dashboard WebSocket

Connect bleRegistry to the dashboard hub so ble_scan messages are
broadcast every 5s to all connected dashboard clients. Add rssi,
last_seen, and blob_id fields to GetCurrentDevices output to match
the frontend's expected message format.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jedarden 2026-04-07 07:50:22 -04:00
parent 92bb8750b7
commit b2d733227b
2 changed files with 14 additions and 5 deletions

View file

@ -652,6 +652,11 @@ func main() {
dashboardHub.SetIngestionState(ingestSrv)
// Wire BLE state to dashboard for ble_scan broadcasts (5s interval)
if bleRegistry != nil {
dashboardHub.SetBLEState(bleRegistry)
}
// Wire zone state to dashboard for occupancy snapshots
if zonesMgr != nil {
dashboardHub.SetZoneState(&zoneStateAdapter{mgr: zonesMgr})
@ -674,9 +679,10 @@ func main() {
}()
}
// Wire ingestion → dashboard for CSI and motion broadcasts
// Wire ingestion → dashboard for CSI, motion, and event broadcasts
ingestSrv.SetDashboardBroadcaster(dashboardHub)
ingestSrv.SetMotionBroadcaster(dashboardHub)
ingestSrv.SetEventBroadcaster(dashboardHub)
// Phase 6: Wire BLE messages to registry and identity matcher
ingestSrv.SetBLEHandler(func(nodeMAC string, devices []ingestion.BLEDevice) {

View file

@ -1373,10 +1373,13 @@ func (r *Registry) GetCurrentDevices() []map[string]interface{} {
result := make([]map[string]interface{}, len(devices))
for i, d := range devices {
result[i] = map[string]interface{}{
"mac": d.Addr,
"name": d.Name,
"label": d.Label,
"manufacturer": d.Manufacturer,
"mac": d.Addr,
"name": d.Name,
"label": d.Label,
"rssi": d.RSSIAvg,
"last_seen": d.LastSeenAt.UnixMilli(),
"blob_id": nil,
"manufacturer": d.Manufacturer,
"device_type": d.DeviceType,
"device_name": d.DeviceName,
"mfr_id": d.MfrID,