resolved disconnected hardware when it is detected

This commit is contained in:
2025-08-31 11:15:38 +02:00
parent 0db468bfef
commit bc15407cad
14 changed files with 96 additions and 80 deletions

View File

@@ -64,7 +64,7 @@ func (a *App) UpdatePeripheralSettings(protocolName, peripheralID string, settin
return f.SetPeripheralSettings(peripheralID, pInfo.Settings)
}
// RemovePeripheral adds a peripheral to the project
// RemovePeripheral removes a peripheral from the project
func (a *App) RemovePeripheral(protocolName string, peripheralID string) error {
// Unregister the peripheral from the finder
f, err := a.hardwareManager.GetFinder(protocolName)
@@ -72,7 +72,7 @@ func (a *App) RemovePeripheral(protocolName string, peripheralID string) error {
log.Err(err).Str("file", "peripherals").Str("protocolName", protocolName).Msg("unable to find the finder")
return fmt.Errorf("unable to find the finder")
}
err = f.UnregisterPeripheral(a.ctx, peripheralID)
err = f.UnregisterPeripheral(peripheralID)
if err != nil {
log.Err(err).Str("file", "peripherals").Str("peripheralID", peripheralID).Msg("unable to unregister this peripheral")
return fmt.Errorf("unable to unregister this peripheral")
@@ -85,19 +85,6 @@ func (a *App) RemovePeripheral(protocolName string, peripheralID string) error {
// FOR TESTING PURPOSE ONLY
// func (a *App) ConnectFTDI() error {
// // Connect the FTDI
// driver, err := a.hardwareManager.GetFinder("FTDI")
// if err != nil {
// return err
// }
// periph, found := driver.GetPeripheral("A50285BI")
// if !found {
// return fmt.Errorf("unable to find the peripheral s/n %s", "A50285BI")
// }
// return periph.Connect(a.ctx)
// }
// func (a *App) ActivateFTDI() error {
// // Connect the FTDI
// driver, err := a.hardwareManager.GetFinder("FTDI")
@@ -136,16 +123,3 @@ func (a *App) RemovePeripheral(protocolName string, peripheralID string) error {
// }
// return periph.Deactivate(a.ctx)
// }
// func (a *App) DisconnectFTDI() error {
// // Connect the FTDI
// driver, err := a.hardwareManager.GetFinder("FTDI")
// if err != nil {
// return err
// }
// periph, found := driver.GetPeripheral("A50285BI")
// if !found {
// return fmt.Errorf("unable to find the peripheral s/n %s", "A50285BI")
// }
// return periph.Disconnect(a.ctx)
// }