diff --git a/Modules/BLEKit/Sources/BLEManager.swift b/Modules/BLEKit/Sources/BLEManager.swift index 9c7ed53ff..a65931030 100644 --- a/Modules/BLEKit/Sources/BLEManager.swift +++ b/Modules/BLEKit/Sources/BLEManager.swift @@ -149,6 +149,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 9ec07d061..822191c3b 100644 --- a/Modules/RobotKit/Sources/Robot.swift +++ b/Modules/RobotKit/Sources/Robot.swift @@ -42,6 +42,10 @@ public class Robot { public var connectedPeripheral: RobotPeripheral? { didSet { + guard self.connectedPeripheral != nil else { + return + } + registerBatteryCharacteristicNotificationCallback() registerChargingStatusNotificationCallback() registerNegotiatedMTUNotificationCallback()