From 009609da93e55a43fe2c9d02c370869f0c7017c6 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 21 Sep 2026 16:50:55 +0100 Subject: [PATCH] fix after implementing new changes to PSS. streaming was broken --- services/devices.go | 4 ++-- services/devices_lookup.go | 6 +++--- tui/internal/controllers/streaming.go | 5 +---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/services/devices.go b/services/devices.go index c162469..8b52d2d 100644 --- a/services/devices.go +++ b/services/devices.go @@ -59,7 +59,7 @@ func (ds *DeviceService) GetDevices() []peripheral.Peripheral { peripherals := make([]peripheral.Peripheral, 0, len(snapshot)) for _, state := range snapshot { - if state.State != DeviceIsConnected { + if state.State < DeviceIsConnected { continue } peripherals = append(peripherals, state.Peripheral) @@ -126,7 +126,7 @@ func (ds *DeviceService) transmit(ctx context.Context) { // TODO: make a copy of the data and send that copy instead of keeping // the data locked for _, dev := range ds.PSS.GetStates() { - if dev.State != DeviceIsConnected { + if dev.State != DeviceIsConfigured { continue } diff --git a/services/devices_lookup.go b/services/devices_lookup.go index 4cefb1e..99cf69b 100644 --- a/services/devices_lookup.go +++ b/services/devices_lookup.go @@ -23,11 +23,11 @@ type DeviceState = uint8 const ( DeviceTimedOut uint8 = iota + DeviceIsDisconnected + DeviceReconnected DeviceIsConnected DeviceIsUnconfigured DeviceIsConfigured - DeviceIsDisconnected - DeviceReconnected ) type PeripheralState struct { @@ -101,7 +101,7 @@ func (pss *PeripheralStateStore) GetPeripheral(pname string) (peripheral.Periphe return nil, err } - if state.State != DeviceIsConnected { + if state.State < DeviceIsConnected { return nil, ErrDeviceIsNotConnected } diff --git a/tui/internal/controllers/streaming.go b/tui/internal/controllers/streaming.go index cb3f211..4fd57c1 100644 --- a/tui/internal/controllers/streaming.go +++ b/tui/internal/controllers/streaming.go @@ -155,10 +155,7 @@ func (sc *StreamingCtrl) updateStream() { // so we can get away with using a map for convenience here func (sc *StreamingCtrl) SetInternalState() { fields := sc.TelemServ.SubscribeToFields() - - // sc.Messages <- fmt.Sprintf("Subscribed Fields: %+v [%d]\n", fields, len(fields)) - // Should I update this? - sc.Messages <- fmt.Sprintf("Subscribed to fields: %+v", fields) + sc.Messages <- fmt.Sprintf("Subscribed to fields: %+v\n", fields) } func (sc *StreamingCtrl) listenToUIStream() {