apply settings for OS2L

This commit is contained in:
2025-11-13 16:00:50 +01:00
parent 18a3a716ef
commit c7d9f35080
6 changed files with 124 additions and 72 deletions

View File

@@ -18,9 +18,10 @@ func (a *App) AddPeripheral(peripheralData hardware.PeripheralInfo) (string, err
// Register this new peripheral
serialNumber, err := f.RegisterPeripheral(a.ctx, peripheralData)
if err != nil {
log.Trace().Str("file", "peripheral").Str("protocolName", peripheralData.ProtocolName).Str("periphID", serialNumber).Msg("device registered to the finder")
return "", fmt.Errorf("unable to register the peripheral '%s'", serialNumber)
return "", fmt.Errorf("unable to register the peripheral '%s': %w", serialNumber, err)
}
log.Trace().Str("file", "peripheral").Str("protocolName", peripheralData.ProtocolName).Str("periphID", serialNumber).Msg("device registered to the finder")
// Rewrite the serialnumber for virtual devices
peripheralData.SerialNumber = serialNumber
@@ -35,7 +36,7 @@ func (a *App) AddPeripheral(peripheralData hardware.PeripheralInfo) (string, err
}
// GetPeripheralSettings gets the peripheral settings
func (a *App) GetPeripheralSettings(protocolName, peripheralID string) (map[string]interface{}, error) {
func (a *App) GetPeripheralSettings(protocolName, peripheralID string) (map[string]any, error) {
// Get the peripheral from its finder
f, err := a.hardwareManager.GetFinder(protocolName)
if err != nil {
@@ -46,7 +47,7 @@ func (a *App) GetPeripheralSettings(protocolName, peripheralID string) (map[stri
}
// UpdatePeripheralSettings updates a specific setting of a peripheral
func (a *App) UpdatePeripheralSettings(protocolName, peripheralID string, settings map[string]interface{}) error {
func (a *App) UpdatePeripheralSettings(protocolName, peripheralID string, settings map[string]any) error {
// Sets the settings with the finder
f, err := a.hardwareManager.GetFinder(protocolName)
if err != nil {
@@ -61,7 +62,7 @@ func (a *App) UpdatePeripheralSettings(protocolName, peripheralID string, settin
pInfo.Settings = settings
a.projectInfo.PeripheralsInfo[peripheralID] = pInfo
// Apply changes in the peripheral
return f.SetPeripheralSettings(peripheralID, pInfo.Settings)
return f.SetPeripheralSettings(a.ctx, peripheralID, pInfo.Settings)
}
// RemovePeripheral removes a peripheral from the project