Skip to content

Commit 35feb4a

Browse files
authored
Merge pull request #100 from LoopKit/support-extensions-and-minimize-scanning
Mark as extension-safe and allow for skipping scanning
2 parents 1262ba9 + e4bcc7e commit 35feb4a

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

CGMBLEKit.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,7 @@
994994
43CABE081C3506F100005705 /* Debug */ = {
995995
isa = XCBuildConfiguration;
996996
buildSettings = {
997+
APPLICATION_EXTENSION_API_ONLY = YES;
997998
CLANG_ENABLE_MODULES = YES;
998999
CODE_SIGN_IDENTITY = "iPhone Developer";
9991000
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
@@ -1016,6 +1017,7 @@
10161017
43CABE091C3506F100005705 /* Release */ = {
10171018
isa = XCBuildConfiguration;
10181019
buildSettings = {
1020+
APPLICATION_EXTENSION_API_ONLY = YES;
10191021
CLANG_ENABLE_MODULES = YES;
10201022
CODE_SIGN_IDENTITY = "iPhone Developer";
10211023
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";

CGMBLEKit/BluetoothManager.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,14 @@ class BluetoothManager: NSObject {
7979
}
8080
}
8181

82+
var peripheralIdentifier: UUID?
83+
8284
var peripheralManager: PeripheralManager? {
8385
didSet {
8486
oldValue?.delegate = nil
8587
peripheralManager?.delegate = self
88+
89+
peripheralIdentifier = peripheralManager?.peripheral.identifier
8690
}
8791
}
8892

@@ -108,7 +112,7 @@ class BluetoothManager: NSObject {
108112
return
109113
}
110114

111-
if let peripheralID = self.peripheral?.identifier, let peripheral = manager.retrievePeripherals(withIdentifiers: [peripheralID]).first {
115+
if let peripheralID = peripheralIdentifier, let peripheral = manager.retrievePeripherals(withIdentifiers: [peripheralID]).first {
112116
log.debug("Re-connecting to known peripheral %{public}@", peripheral.identifier.uuidString)
113117
self.peripheral = peripheral
114118
self.manager.connect(peripheral)

CGMBLEKit/Transmitter.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,11 @@ public final class Transmitter: BluetoothManagerDelegate {
9090

9191
private let delegateQueue = DispatchQueue(label: "com.loudnate.CGMBLEKit.delegateQueue", qos: .utility)
9292

93-
public init(id: String, passiveModeEnabled: Bool = false) {
93+
public init(id: String, peripheralIdentifier: UUID? = nil, passiveModeEnabled: Bool = false) {
9494
self.id = TransmitterID(id: id)
9595
self.passiveModeEnabled = passiveModeEnabled
9696

97+
bluetoothManager.peripheralIdentifier = peripheralIdentifier
9798
bluetoothManager.delegate = self
9899
}
99100

@@ -111,6 +112,15 @@ public final class Transmitter: BluetoothManagerDelegate {
111112
return bluetoothManager.isScanning
112113
}
113114

115+
public var peripheralIdentifier: UUID? {
116+
get {
117+
return bluetoothManager.peripheralIdentifier
118+
}
119+
set {
120+
bluetoothManager.peripheralIdentifier = newValue
121+
}
122+
}
123+
114124
public var stayConnected: Bool {
115125
get {
116126
return bluetoothManager.stayConnected

0 commit comments

Comments
 (0)