generated from thinkode/modelRepository
fix project life and plug-and-replay on peripherals
This commit is contained in:
@@ -65,21 +65,21 @@ func (a *App) UpdatePeripheralSettings(protocolName, peripheralID string, settin
|
||||
}
|
||||
|
||||
// RemovePeripheral removes a peripheral from the project
|
||||
func (a *App) RemovePeripheral(protocolName string, peripheralID string) error {
|
||||
func (a *App) RemovePeripheral(peripheralData hardware.PeripheralInfo) error {
|
||||
// Unregister the peripheral from the finder
|
||||
f, err := a.hardwareManager.GetFinder(protocolName)
|
||||
f, err := a.hardwareManager.GetFinder(peripheralData.ProtocolName)
|
||||
if err != nil {
|
||||
log.Err(err).Str("file", "peripherals").Str("protocolName", protocolName).Msg("unable to find the finder")
|
||||
log.Err(err).Str("file", "peripherals").Str("protocolName", peripheralData.ProtocolName).Msg("unable to find the finder")
|
||||
return fmt.Errorf("unable to find the finder")
|
||||
}
|
||||
err = f.UnregisterPeripheral(a.ctx, peripheralID)
|
||||
err = f.UnregisterPeripheral(a.ctx, peripheralData)
|
||||
if err != nil {
|
||||
log.Err(err).Str("file", "peripherals").Str("peripheralID", peripheralID).Msg("unable to unregister this peripheral")
|
||||
log.Err(err).Str("file", "peripherals").Str("peripheralID", peripheralData.SerialNumber).Msg("unable to unregister this peripheral")
|
||||
return fmt.Errorf("unable to unregister this peripheral")
|
||||
}
|
||||
// Remove the peripheral ID from the project
|
||||
delete(a.projectInfo.PeripheralsInfo, peripheralID)
|
||||
log.Info().Str("file", "peripheral").Str("protocolName", protocolName).Str("periphID", peripheralID).Msg("peripheral removed from project")
|
||||
delete(a.projectInfo.PeripheralsInfo, peripheralData.SerialNumber)
|
||||
log.Info().Str("file", "peripheral").Str("protocolName", peripheralData.ProtocolName).Str("periphID", peripheralData.SerialNumber).Msg("peripheral removed from project")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user