diff --git a/Package.pins b/Package.pins index b85980c..02ee9d8 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.2" + "version": "1.5.3" } ], "version": 1 diff --git a/Sources/BluetoothLinux/GATTClient.swift b/Sources/BluetoothLinux/GATTClient.swift index cc5fa20..74bd2b4 100755 --- a/Sources/BluetoothLinux/GATTClient.swift +++ b/Sources/BluetoothLinux/GATTClient.swift @@ -460,7 +460,7 @@ public extension GATTClient { public let uuid: BluetoothUUID - public let properties: Set + public let properties: BitMaskOptionSet public let handle: (declaration: UInt16, value: UInt16) } @@ -516,7 +516,7 @@ internal extension GATTClient { /// Characteristic Properties /// /// Bit field of characteristic properties. - var properties: Set + var properties: BitMaskOptionSet /// Characteristic Value Handle /// @@ -533,7 +533,7 @@ internal extension GATTClient { guard let length = Length(rawValue: bytes.count) else { return nil } - let properties = Property.from(flags: bytes[0]) + let properties = BitMaskOptionSet(rawValue: bytes[0]) let valueHandle = UInt16(littleEndian: UInt16(bytes: (bytes[1], bytes[2]))) diff --git a/Sources/BluetoothLinux/GATTDatabase.swift b/Sources/BluetoothLinux/GATTDatabase.swift index cb20f50..4a1dcd0 100644 --- a/Sources/BluetoothLinux/GATTDatabase.swift +++ b/Sources/BluetoothLinux/GATTDatabase.swift @@ -230,7 +230,7 @@ public extension GATTDatabase { let declarationAttribute: Attribute = { - let propertiesMask = characteristic.properties.flags + let propertiesMask = characteristic.properties.rawValue let valueHandleBytes = (handle + 1).littleEndian.bytes let value = [propertiesMask, valueHandleBytes.0, valueHandleBytes.1] + characteristic.uuid.littleEndianData diff --git a/Sources/BluetoothLinux/Scan.swift b/Sources/BluetoothLinux/Scan.swift index 2a57b05..35bb8ff 100644 --- a/Sources/BluetoothLinux/Scan.swift +++ b/Sources/BluetoothLinux/Scan.swift @@ -29,13 +29,13 @@ public extension Adapter { /// - Parameter deviceClass: Device class to filter results by. /// /// - Parameter options: Array of ```ScanOption```. - func scan(duration: Int = 8, limit: Int = 255, deviceClass: DeviceClass? = nil, options: [ScanOption] = []) throws -> [InquiryResult] { + func scan(duration: Int = 8, limit: Int = 255, deviceClass: DeviceClass? = nil, options: BitMaskOptionSet = []) throws -> [InquiryResult] { assert(duration > 0, "Scan must be longer than 0 seconds") assert(limit > 0, "Must scan at least one device") assert(limit <= 255, "Cannot be larger than UInt8.max") - let flags = options.flags + let flags = options.rawValue return try HCIInquiry(identifier, duration: duration, scanLimit: limit, deviceClass: deviceClass, flags: flags) } @@ -76,10 +76,7 @@ public extension Adapter { public static let all: Set = [.flushCache] - #if swift(>=3.1) - #elseif swift(>=3.0) public typealias RawValue = Int32 - #endif } public struct InquiryResult { diff --git a/Tests/BluetoothLinuxTests/DataTests.swift b/Tests/BluetoothLinuxTests/DataTests.swift index 94f5eb8..8a9fd64 100644 --- a/Tests/BluetoothLinuxTests/DataTests.swift +++ b/Tests/BluetoothLinuxTests/DataTests.swift @@ -43,7 +43,8 @@ final class DataTests: XCTestCase { XCTAssert(characteristicDeclaration.valueHandle == 42) XCTAssert(characteristicDeclaration.uuid == characteristic.uuid) - XCTAssert(characteristicDeclaration.properties == Set(characteristic.properties)) + XCTAssert(characteristicDeclaration.properties.set == Set(characteristic.properties)) + XCTAssert(characteristicDeclaration.properties == characteristic.properties) } } }