generated from thinkode/modelRepository
77 lines
2.3 KiB
Go
77 lines
2.3 KiB
Go
package hardware
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
// OS2LPeripheral contains the data of an OS2L peripheral
|
|
type OS2LPeripheral struct {
|
|
name string // The name of the peripheral
|
|
serialNumber string // The serial number of the peripheral
|
|
settings map[string]interface{} // The settings of the peripheral
|
|
}
|
|
|
|
// NewOS2LPeripheral creates a new OS2L peripheral
|
|
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["os2lIpSetting"] = "192.168.1.1"
|
|
settings["os2lPortSetting"] = 9995
|
|
return &OS2LPeripheral{
|
|
name: name,
|
|
serialNumber: serialNumber,
|
|
settings: settings,
|
|
}
|
|
}
|
|
|
|
// Connect connects the MIDI peripheral
|
|
func (p *OS2LPeripheral) Connect(ctx context.Context) error {
|
|
log.Info().Str("file", "OS2LPeripheral").Msg("OS2L peripheral connected")
|
|
return nil
|
|
}
|
|
|
|
// Disconnect disconnects the MIDI peripheral
|
|
func (p *OS2LPeripheral) Disconnect(ctx context.Context) error {
|
|
log.Info().Str("file", "OS2LPeripheral").Msg("OS2L peripheral disconnected")
|
|
return nil
|
|
}
|
|
|
|
// Activate activates the MIDI peripheral
|
|
func (p *OS2LPeripheral) Activate(ctx context.Context) error {
|
|
log.Info().Str("file", "OS2LPeripheral").Msg("OS2L peripheral activated")
|
|
return nil
|
|
}
|
|
|
|
// Deactivate deactivates the MIDI peripheral
|
|
func (p *OS2LPeripheral) Deactivate(ctx context.Context) error {
|
|
log.Info().Str("file", "OS2LPeripheral").Msg("OS2L peripheral deactivated")
|
|
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
|
|
}
|
|
|
|
// GetSettings gets the peripheral settings
|
|
func (p *OS2LPeripheral) GetSettings() map[string]interface{} {
|
|
return p.settings
|
|
}
|
|
|
|
// GetInfo gets the peripheral information
|
|
func (p *OS2LPeripheral) GetInfo() PeripheralInfo {
|
|
return PeripheralInfo{
|
|
Name: p.name,
|
|
SerialNumber: p.serialNumber,
|
|
ProtocolName: "OS2L",
|
|
}
|
|
}
|