fixed: create peripheral

This commit is contained in:
2025-11-30 18:33:00 +01:00
parent d1fda9f075
commit 7f60f7b8d7
8 changed files with 83 additions and 138 deletions

View File

@@ -22,8 +22,8 @@ type MIDIFinder struct {
scanEvery time.Duration // Scans peripherals periodically
onArrival func(context.Context, Peripheral, bool) // When a peripheral arrives
onRemoval func(context.Context, Peripheral) // When a peripheral goes away
onArrival func(context.Context, Peripheral) // When a peripheral arrives
onRemoval func(context.Context, Peripheral) // When a peripheral goes away
}
// NewMIDIFinder creates a new MIDI finder
@@ -36,7 +36,7 @@ func NewMIDIFinder(scanEvery time.Duration) *MIDIFinder {
}
// OnArrival is the callback function when a new peripheral arrives
func (f *MIDIFinder) OnArrival(cb func(context.Context, Peripheral, bool)) {
func (f *MIDIFinder) OnArrival(cb func(context.Context, Peripheral)) {
f.onArrival = cb
}
@@ -52,8 +52,8 @@ func (f *MIDIFinder) Initialize() error {
}
// Create creates a new peripheral, based on the peripheral information (manually created)
func (f *MIDIFinder) Create(ctx context.Context, peripheralInfo PeripheralInfo) error {
return nil
func (f *MIDIFinder) Create(ctx context.Context, peripheralInfo PeripheralInfo) (PeripheralInfo, error) {
return PeripheralInfo{}, nil
}
// Remove removes an existing peripheral (manually created)
@@ -201,7 +201,7 @@ func (f *MIDIFinder) scanPeripherals(ctx context.Context) error {
f.detected[sn] = peripheral
if f.onArrival != nil {
f.onArrival(ctx, discovery, false)
f.onArrival(ctx, discovery)
}
}
}