From 628d2e36e2012a0b2718c96fb15bcefd45929978 Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Mon, 26 Aug 2024 15:33:56 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=97=EF=B8=8F=20(BLEKit):=20Try=20and=20fi?= =?UTF-8?q?x=20double=20connection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Modules/BLEKit/Sources/BLEManager.swift | 1 + Modules/RobotKit/Sources/Robot.swift | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Modules/BLEKit/Sources/BLEManager.swift b/Modules/BLEKit/Sources/BLEManager.swift index 3160d19207..7f27984028 100644 --- a/Modules/BLEKit/Sources/BLEManager.swift +++ b/Modules/BLEKit/Sources/BLEManager.swift @@ -151,6 +151,7 @@ public class BLEManager { private func subscribeToDidDisconnect() { self.centralManager.didDisconnectPeripheral .sink { _ in + self.connectedRobotPeripheral = nil self.didDisconnect.send() } .store(in: &self.cancellables) diff --git a/Modules/RobotKit/Sources/Robot.swift b/Modules/RobotKit/Sources/Robot.swift index 47faa39f8b..437071a5d9 100644 --- a/Modules/RobotKit/Sources/Robot.swift +++ b/Modules/RobotKit/Sources/Robot.swift @@ -41,6 +41,10 @@ public class Robot { public var connectedPeripheral: RobotPeripheral? { didSet { + guard self.connectedPeripheral != nil else { + return + } + registerBatteryCharacteristicNotificationCallback() registerChargingStatusNotificationCallback() registerNegotiatedMTUNotificationCallback()