fixed multiple MIDI devices S/N

This commit is contained in:
2024-12-26 14:55:55 +01:00
9 changed files with 142 additions and 36 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"math/rand"
"strings"
)
// OS2LDriver represents how the protocol is defined
@@ -27,7 +28,7 @@ func (d *OS2LDriver) Initialize() error {
// CreatePeripheral creates a new OS2L peripheral
func (d *OS2LDriver) CreatePeripheral(ctx context.Context) (Peripheral, error) {
// Create a random serial number for this peripheral
randomSerialNumber := fmt.Sprintf("%08x", rand.Intn(1<<32))
randomSerialNumber := strings.ToUpper(fmt.Sprintf("%08x", rand.Intn(1<<32)))
peripheral := NewOS2LPeripheral("OS2L", randomSerialNumber)
d.peripherals[randomSerialNumber] = peripheral
return peripheral, nil