Last active
January 24, 2021 19:33
-
-
Save Kdan/e2a0ae486f5b593a6ac485f67323274e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// A Facade for the CBCentralManager. | |
protocol CentralManager { | |
/// The delegate of the central manager. | |
var delegate: CBCentralManagerDelegate? { get set } | |
/// The state of the central manager. | |
var state: CBManagerState { get } | |
/// Call this function to scan for bluetooth peripherals. | |
func scanForPeripherals(withServices serviceUUIDs: [CBUUID]?) | |
/// Connect to a peripheral. | |
func connect(_ peripheral: Peripheral, options: [String : Any]?) | |
} | |
extension CBCentralManager: CentralManager { | |
func connect(_ peripheral: Peripheral, options: [String : Any]?) { | |
guard let peripheral = peripheral as? CBPeripheral else { fatalError() } | |
connect(peripheral, options: nil) | |
} | |
} | |
/// A Facade for the CBPeripheral. | |
protocol Peripheral { | |
/// The name of the peripheral | |
var name: String? { get } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment