peripheral setting save

This commit is contained in:
2025-01-25 16:00:02 +01:00
parent 0114ed03bf
commit 9d00b99730
9 changed files with 70 additions and 18 deletions

View File

@@ -38,7 +38,6 @@ type FTDIPeripheral struct {
func NewFTDIPeripheral(name string, serialNumber string, location int) (*FTDIPeripheral, error) {
log.Info().Str("file", "FTDIPeripheral").Str("name", name).Str("s/n", serialNumber).Int("location", location).Msg("FTDI peripheral created")
settings := make(map[string]interface{})
settings["universesNumber"] = uint64(1)
return &FTDIPeripheral{
name: name,
dmxSender: nil,
@@ -172,6 +171,12 @@ func (p *FTDIPeripheral) Deactivate(ctx context.Context) error {
return fmt.Errorf("unable to deactivate: not connected")
}
// SetPeripheralSetting sets a specific setting for this peripheral
func (p *FTDIPeripheral) SetPeripheralSetting(settingName string, settingValue interface{}) error {
p.settings[settingName] = settingValue
return nil
}
// SetDeviceProperty sends a command to the specified device
func (p *FTDIPeripheral) SetDeviceProperty(ctx context.Context, uint32, channelNumber uint32, channelValue byte) error {
if p.dmxSender != nil {

View File

@@ -46,6 +46,12 @@ func (p *MIDIPeripheral) Deactivate(ctx context.Context) error {
return nil
}
// SetPeripheralSetting sets a specific setting for this peripheral
func (p *MIDIPeripheral) SetPeripheralSetting(settingName string, settingValue interface{}) error {
p.settings[settingName] = settingValue
return nil
}
// SetDeviceProperty - not implemented for this kind of peripheral
func (p *MIDIPeripheral) SetDeviceProperty(context.Context, uint32, uint32, byte) error {
return nil

View File

@@ -17,8 +17,8 @@ type OS2LPeripheral struct {
func NewOS2LPeripheral(name string, serialNumber string) *OS2LPeripheral {
log.Trace().Str("file", "OS2LPeripheral").Str("name", name).Str("s/n", serialNumber).Msg("OS2L peripheral created")
settings := make(map[string]interface{})
settings["ip"] = "192.168.1.1"
settings["port"] = 9995
settings["os2lIpSetting"] = "192.168.1.1"
settings["os2lPortSetting"] = 9995
return &OS2LPeripheral{
name: name,
serialNumber: serialNumber,
@@ -50,6 +50,12 @@ func (p *OS2LPeripheral) Deactivate(ctx context.Context) error {
return nil
}
// SetPeripheralSetting sets a specific setting for this peripheral
func (p *OS2LPeripheral) SetPeripheralSetting(settingName string, settingValue interface{}) error {
p.settings[settingName] = settingValue
return nil
}
// SetDeviceProperty - not implemented for this kind of peripheral
func (p *OS2LPeripheral) SetDeviceProperty(context.Context, uint32, uint32, byte) error {
return nil

View File

@@ -8,6 +8,7 @@ type Peripheral interface {
Disconnect(context.Context) error // Disconnect the peripheral
Activate(context.Context) error // Activate the peripheral
Deactivate(context.Context) error // Deactivate the peripheral
SetPeripheralSetting(string, interface{}) error // Set a peripheral setting
SetDeviceProperty(context.Context, uint32, uint32, byte) error // Update a device property
GetInfo() PeripheralInfo // Get the peripheral information