From 0330b8802d87c89aba9802f1c1d0bdfa58cb6960 Mon Sep 17 00:00:00 2001 From: Alexis Couvreur Date: Mon, 30 Mar 2026 22:33:39 +0200 Subject: [PATCH] fix(darwin): add DidFailToConnectPeripheral handler --- adapter_darwin.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/adapter_darwin.go b/adapter_darwin.go index 9c4acc0d..55e20405 100644 --- a/adapter_darwin.go +++ b/adapter_darwin.go @@ -131,6 +131,17 @@ func (cmd *centralManagerDelegate) DidConnectPeripheral(cmgr cbgo.CentralManager } } +// DidFailToConnectPeripheral when peripheral connection fails. +func (cmd *centralManagerDelegate) DidFailToConnectPeripheral(cmgr cbgo.CentralManager, prph cbgo.Peripheral, err error) { + id := prph.Identifier().String() + + // Send the peripheral through so ConnectWithContext can check its state + // and return the appropriate error. + if ch, ok := cmd.a.connectMap.LoadAndDelete(id); ok { + ch.(chan cbgo.Peripheral) <- prph + } +} + // makeScanResult creates a ScanResult when peripheral is found. func makeScanResult(prph cbgo.Peripheral, advFields cbgo.AdvFields, rssi int) ScanResult { uuid, _ := ParseUUID(prph.Identifier().String())