resolved created peripheral

This commit is contained in:
2025-11-29 20:06:04 +01:00
parent 2dc6f4a38a
commit d1fda9f075
8 changed files with 112 additions and 42 deletions

View File

@@ -22,8 +22,8 @@ type MIDIFinder struct {
scanEvery time.Duration // Scans peripherals periodically
onArrival func(context.Context, Peripheral) // When a peripheral arrives
onRemoval func(context.Context, Peripheral) // When a peripheral goes away
onArrival func(context.Context, Peripheral, bool) // 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)) {
func (f *MIDIFinder) OnArrival(cb func(context.Context, Peripheral, bool)) {
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) (string, error) {
return "", nil
func (f *MIDIFinder) Create(ctx context.Context, peripheralInfo PeripheralInfo) error {
return 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)
f.onArrival(ctx, discovery, false)
}
}
}