diff --git a/Modules/BLEKit/Sources/BLEManager.swift b/Modules/BLEKit/Sources/BLEManager.swift index 3160d1920..7f2798402 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 47faa39f8..437071a5d 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()