peripheral can connect mid stream and start go into streaming immidiately

This commit is contained in:
2026-09-23 13:40:31 +01:00
parent 76d758e264
commit a519cf473e
6 changed files with 53 additions and 25 deletions
+11 -2
View File
@@ -85,7 +85,8 @@ type PeripheralStateStore struct {
// Messaging for UI and stuff
Messages chan string
// Callbacks
telemetryProvider func() (string, error)
telemetryProvider func() (string, error)
onPeripheralConfigured func(string)
// Internal State
isStreaming bool
}
@@ -204,6 +205,12 @@ func (pss *PeripheralStateStore) OnStopStream() {
pss.mu.Lock()
pss.isStreaming = false
pss.mu.Unlock()
for _, state := range pss.GetStates() {
if state.State == DeviceIsStreaming {
pss.setDeviceConfigured(state.device.Name)
}
}
}
// "Events" [END] --------------------------------------------------------------
@@ -270,8 +277,10 @@ func (pss *PeripheralStateStore) setDeviceConfigured(pname string) {
pss.Logger.Info("device is configured and ready for data", "device", pname)
pss.mu.Lock()
defer pss.mu.Unlock()
pss.store[pname].State = DeviceIsConfigured
pss.mu.Unlock()
pss.onPeripheralConfigured(pname)
}
func (pss *PeripheralStateStore) setDeviceIsStreaming(pname string) {