resolved created peripheral

This commit is contained in:
2025-11-29 20:06:04 +01:00
parent 2dc6f4a38a
commit d1fda9f075
8 changed files with 112 additions and 42 deletions

View File

@@ -7,6 +7,12 @@ import (
"github.com/rs/zerolog/log"
)
// CreatePeripheral creates a new peripheral from the hardware manager
func (a *App) CreatePeripheral(peripheralData hardware.PeripheralInfo) (string, error) {
a.hardwareManager.CreatePeripheral(a.ctx, peripheralData)
return "", nil
}
// AddPeripheral adds a peripheral to the project
func (a *App) AddPeripheral(peripheralData hardware.PeripheralInfo) (string, error) {
// Register this new peripheral
@@ -29,17 +35,6 @@ func (a *App) AddPeripheral(peripheralData hardware.PeripheralInfo) (string, err
return peripheralData.SerialNumber, nil
}
// CreatePeripheral creates a new peripheral
func (a *App) CreatePeripheral(peripheralData hardware.PeripheralInfo) (string, error) {
// Get the appropriate finder to create the device
finder, err := a.hardwareManager.GetFinder(peripheralData.ProtocolName)
if err != nil {
return "", fmt.Errorf("unable to find the appropriate finder (%s): %w", peripheralData.ProtocolName, err)
}
// Manually create the peripheral from its finder
return finder.Create(a.ctx, peripheralData)
}
// GetPeripheralSettings gets the peripheral settings
func (a *App) GetPeripheralSettings(protocolName, peripheralSN string) (map[string]any, error) {
return a.hardwareManager.GetPeripheralSettings(peripheralSN)