Device reconnection handling #15
+2
-2
@@ -59,7 +59,7 @@ func (ds *DeviceService) GetDevices() []peripheral.Peripheral {
|
|||||||
peripherals := make([]peripheral.Peripheral, 0, len(snapshot))
|
peripherals := make([]peripheral.Peripheral, 0, len(snapshot))
|
||||||
|
|
||||||
for _, state := range snapshot {
|
for _, state := range snapshot {
|
||||||
if state.State != DeviceIsConnected {
|
if state.State < DeviceIsConnected {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
peripherals = append(peripherals, state.Peripheral)
|
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
|
// TODO: make a copy of the data and send that copy instead of keeping
|
||||||
// the data locked
|
// the data locked
|
||||||
for _, dev := range ds.PSS.GetStates() {
|
for _, dev := range ds.PSS.GetStates() {
|
||||||
if dev.State != DeviceIsConnected {
|
if dev.State != DeviceIsConfigured {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ type DeviceState = uint8
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
DeviceTimedOut uint8 = iota
|
DeviceTimedOut uint8 = iota
|
||||||
|
DeviceIsDisconnected
|
||||||
|
DeviceReconnected
|
||||||
DeviceIsConnected
|
DeviceIsConnected
|
||||||
DeviceIsUnconfigured
|
DeviceIsUnconfigured
|
||||||
DeviceIsConfigured
|
DeviceIsConfigured
|
||||||
DeviceIsDisconnected
|
|
||||||
DeviceReconnected
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type PeripheralState struct {
|
type PeripheralState struct {
|
||||||
@@ -101,7 +101,7 @@ func (pss *PeripheralStateStore) GetPeripheral(pname string) (peripheral.Periphe
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if state.State != DeviceIsConnected {
|
if state.State < DeviceIsConnected {
|
||||||
return nil, ErrDeviceIsNotConnected
|
return nil, ErrDeviceIsNotConnected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -155,10 +155,7 @@ func (sc *StreamingCtrl) updateStream() {
|
|||||||
// so we can get away with using a map for convenience here
|
// so we can get away with using a map for convenience here
|
||||||
func (sc *StreamingCtrl) SetInternalState() {
|
func (sc *StreamingCtrl) SetInternalState() {
|
||||||
fields := sc.TelemServ.SubscribeToFields()
|
fields := sc.TelemServ.SubscribeToFields()
|
||||||
|
sc.Messages <- fmt.Sprintf("Subscribed to fields: %+v\n", fields)
|
||||||
// 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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sc *StreamingCtrl) listenToUIStream() {
|
func (sc *StreamingCtrl) listenToUIStream() {
|
||||||
|
|||||||
Reference in New Issue
Block a user