Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚗️ (BLEKit): Try and fix double connection #1382

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Modules/BLEKit/Sources/BLEManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
private func subscribeToDidDisconnect() {
self.centralManager.didDisconnectPeripheral
.sink { _ in
self.connectedRobotPeripheral = nil
self.didDisconnect.send()
}
.store(in: &self.cancellables)
Expand All @@ -159,7 +160,7 @@
.sink { state in
self.state.send(state)
if state == .poweredOn {
self.retrieveConnectedRobots()

Check warning on line 163 in Modules/BLEKit/Sources/BLEManager.swift

View workflow job for this annotation

GitHub Actions / build (true)

result of call to 'retrieveConnectedRobots()' is unused

Check warning on line 163 in Modules/BLEKit/Sources/BLEManager.swift

View workflow job for this annotation

GitHub Actions / build (false)

result of call to 'retrieveConnectedRobots()' is unused
}
if state == .poweredOff {
self.disconnect()
Expand All @@ -171,7 +172,7 @@

// MARK: - CBManagerState + CustomStringConvertible

extension CBManagerState: CustomStringConvertible {

Check warning on line 175 in Modules/BLEKit/Sources/BLEManager.swift

View workflow job for this annotation

GitHub Actions / build (true)

extension declares a conformance of imported type 'CBManagerState' to imported protocol 'CustomStringConvertible'; this will not behave correctly if the owners of 'CoreBluetooth' introduce this conformance in the future

Check warning on line 175 in Modules/BLEKit/Sources/BLEManager.swift

View workflow job for this annotation

GitHub Actions / build (true)

extension declares a conformance of imported type 'CBManagerState' to imported protocol 'CustomStringConvertible'; this will not behave correctly if the owners of 'CoreBluetooth' introduce this conformance in the future

Check warning on line 175 in Modules/BLEKit/Sources/BLEManager.swift

View workflow job for this annotation

GitHub Actions / build (false)

extension declares a conformance of imported type 'CBManagerState' to imported protocol 'CustomStringConvertible'; this will not behave correctly if the owners of 'CoreBluetooth' introduce this conformance in the future

Check warning on line 175 in Modules/BLEKit/Sources/BLEManager.swift

View workflow job for this annotation

GitHub Actions / build (false)

extension declares a conformance of imported type 'CBManagerState' to imported protocol 'CustomStringConvertible'; this will not behave correctly if the owners of 'CoreBluetooth' introduce this conformance in the future
public var description: String {
switch self {
case .poweredOn:
Expand Down
4 changes: 4 additions & 0 deletions Modules/RobotKit/Sources/Robot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public class Robot {

public var connectedPeripheral: RobotPeripheral? {
didSet {
guard self.connectedPeripheral != nil else {
return
}

registerBatteryCharacteristicNotificationCallback()
registerChargingStatusNotificationCallback()
registerNegotiatedMTUNotificationCallback()
Expand Down
Loading