Skip to content

Commit

Permalink
Add missing CentralManager delegate events
Browse files Browse the repository at this point in the history
  • Loading branch information
manolofdez authored Sep 7, 2022
2 parents 68090a6 + 2aa9a61 commit fb709a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Sources/CentralManager/CentralManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ extension CentralManager.DelegateWrapper: CBCentralManagerDelegate {
}
}

func centralManager(_ central: CBCentralManager, willRestoreState dict: [String : Any]) {
self.context.eventSubject.send(.willRestoreState(state: dict))
}

func centralManager(
_ cbCentralManager: CBCentralManager,
didDiscover cbPeripheral: CBPeripheral,
Expand Down Expand Up @@ -239,8 +243,12 @@ extension CentralManager.DelegateWrapper: CBCentralManagerDelegate {
peripheral.identifier, result:.success(())
)
} catch {
Self.logger.error("Received onDidConnect without a continuation!")
Self.logger.info("Received onDidConnect without a continuation")
}

self.context.eventSubject.send(
.didConnectPeripheral(peripheral: Peripheral(peripheral))
)
}
}

Expand Down
3 changes: 2 additions & 1 deletion Sources/CentralManager/CentralManagerEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import CoreBluetooth

public enum CentralManagerEvent {
case didUpdateState(state: CBManagerState)
case willRestoreState(state: [String: Any])
case didConnectPeripheral(peripheral: Peripheral)
case didDisconnectPeripheral(peripheral: Peripheral, error: Error?)
}

0 comments on commit fb709a4

Please sign in to comment.