diff --git a/Package.pins b/Package.pins index 22cf040..b85980c 100644 --- a/Package.pins +++ b/Package.pins @@ -5,7 +5,7 @@ "package": "Bluetooth", "reason": null, "repositoryURL": "https://github.com/PureSwift/Bluetooth.git", - "version": "1.5.0" + "version": "1.5.2" } ], "version": 1 diff --git a/Sources/BluetoothLinux/GATTClient.swift b/Sources/BluetoothLinux/GATTClient.swift index fc9b9fe..cc5fa20 100755 --- a/Sources/BluetoothLinux/GATTClient.swift +++ b/Sources/BluetoothLinux/GATTClient.swift @@ -202,18 +202,11 @@ public final class GATTClient { foundData: [], completion: completion) - if let uuid = uuid { - - - - } else { - - let pdu = ATTReadByTypeRequest(startHandle: service.handle, - endHandle: service.end, - attributeType: attributeType.uuid) - - send(pdu) { [unowned self] in self.readByType($0, operation: operation) } - } + let pdu = ATTReadByTypeRequest(startHandle: service.handle, + endHandle: service.end, + attributeType: attributeType.uuid) + + send(pdu) { [unowned self] in self.readByType($0, operation: operation) } } // MARK: - Callbacks @@ -386,6 +379,14 @@ public final class GATTClient { handle: (handle, declaration.valueHandle)) operation.foundData.append(characteristic) + + // if we specified a UUID to be searched, + // then call completion if it matches + if let operationUUID = operation.uuid { + + guard characteristic.uuid != operationUUID + else { operation.success(); return } + } } // get more if possible @@ -408,6 +409,7 @@ public final class GATTClient { } else { + // end of service operation.success() } } diff --git a/Sources/BluetoothLinux/GATTDatabase.swift b/Sources/BluetoothLinux/GATTDatabase.swift index 7423e69..cb20f50 100644 --- a/Sources/BluetoothLinux/GATTDatabase.swift +++ b/Sources/BluetoothLinux/GATTDatabase.swift @@ -189,7 +189,7 @@ public extension GATTDatabase { public let uuid: BluetoothUUID - public let permissions: [Permission] + public let permissions: BitMaskOptionSet public var value: Data @@ -197,7 +197,7 @@ public extension GATTDatabase { fileprivate init(handle: UInt16, uuid: BluetoothUUID, value: Data = Data(), - permissions: [Permission] = []) { + permissions: BitMaskOptionSet = []) { self.handle = handle self.uuid = uuid diff --git a/Sources/BluetoothLinux/GATTServer.swift b/Sources/BluetoothLinux/GATTServer.swift index b4385b4..fcf9507 100644 --- a/Sources/BluetoothLinux/GATTServer.swift +++ b/Sources/BluetoothLinux/GATTServer.swift @@ -138,7 +138,8 @@ public final class GATTServer { else { fatalError("Could not add PDU to queue: \(response)") } } - private func checkPermissions(_ permissions: [ATT.AttributePermission], _ attribute: GATTDatabase.Attribute) -> ATT.Error? { + private func checkPermissions(_ permissions: BitMaskOptionSet, + _ attribute: GATTDatabase.Attribute) -> ATT.Error? { guard attribute.permissions != permissions else { return nil }