From 35207e7c1c2d88d6094c541662aff74173ed4715 Mon Sep 17 00:00:00 2001 From: hu13 Date: Sun, 23 Feb 2025 15:39:55 -0500 Subject: [PATCH] Fix issue 284 --- adapter_darwin.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/adapter_darwin.go b/adapter_darwin.go index 71b53e7..8562ca4 100644 --- a/adapter_darwin.go +++ b/adapter_darwin.go @@ -10,9 +10,9 @@ import ( // Adapter is a connection to BLE devices. type Adapter struct { - id string - cmd *centralManagerDelegate - pmd *peripheralManagerDelegate + macAddress string + cmd *centralManagerDelegate + pmd *peripheralManagerDelegate cm cbgo.CentralManager pm cbgo.PeripheralManager @@ -28,12 +28,13 @@ type Adapter struct { connectHandler func(device Device, connected bool) } -// NewAdapter creates a new Adapter with the given ID. -// +// NewAdapter creates a new Adapter with the given macAddress. +// this is to support a system with multiple bluetooth adapters. +// macAddress can be found by running `system_profiler SPBluetoothDataType` // Make sure to call Enable() before using it to initialize the adapter. -func NewAdapter(id string) *Adapter { +func NewAdapter(macAddress string) *Adapter { return &Adapter{ - id: id, + macAddress: macAddress, cm: cbgo.NewCentralManager(nil), pm: cbgo.NewPeripheralManager(nil), connectMap: sync.Map{},