corrected events

This commit is contained in:
2025-11-10 14:18:22 +01:00
parent 9e8cbed73f
commit f8b39d90de
10 changed files with 620 additions and 164 deletions

View File

@@ -11,6 +11,7 @@ import (
"unsafe"
"github.com/rs/zerolog/log"
"github.com/wailsapp/wails/v2/pkg/runtime"
)
/*
@@ -52,6 +53,9 @@ func (f *FTDIFinder) RegisterPeripheral(ctx context.Context, peripheralData Peri
f.registeredPeripherals[peripheralData.SerialNumber] = ftdiPeripheral
log.Trace().Any("periph", &ftdiPeripheral).Str("file", "FTDIFinder").Str("peripheralName", peripheralData.Name).Msg("FTDI peripheral has been created")
// Emit the event to the front
runtime.EventsEmit(ctx, "LOAD_PERIPHERAL", peripheralData)
// Peripheral created, connect it
err = ftdiPeripheral.Connect(ctx)
if err != nil {
@@ -80,8 +84,12 @@ func (f *FTDIFinder) UnregisterPeripheral(ctx context.Context, peripheralID stri
if err != nil {
return err
}
delete(f.registeredPeripherals, peripheralID)
// Emit the event to the front
runtime.EventsEmit(ctx, "UNLOAD_PERIPHERAL", peripheral.info)
}
delete(f.registeredPeripherals, peripheralID)
return nil
}