diff --git a/Sources/BluetoothGATT/ATTFindInformationResponse.swift b/Sources/BluetoothGATT/ATTFindInformationResponse.swift index 92afc359e..17eb8d5c6 100644 --- a/Sources/BluetoothGATT/ATTFindInformationResponse.swift +++ b/Sources/BluetoothGATT/ATTFindInformationResponse.swift @@ -7,6 +7,7 @@ // import Foundation +import Bluetooth /// Find Information Response /// @@ -227,7 +228,7 @@ public extension ATTFindInformationResponse { let uuid = UInt16(littleEndian: UInt16(bytes: (pairBytes[2], pairBytes[3]))) bit16Pairs.append(Attribute16Bit(handle: handle, uuid: uuid)) case .bit128: - let uuidBytes = pairBytes.subdataNoCopy(in: 2 ..< 18) + let uuidBytes = pairBytes.subdata(in: 2 ..< 18) let uuid = UInt128(littleEndian: UInt128(data: uuidBytes)!) bit128Pairs.append(Attribute128Bit(handle: handle, uuid: uuid)) } diff --git a/Sources/BluetoothGATT/GAPUUIDList.swift b/Sources/BluetoothGATT/GAPUUIDList.swift index 1747d676a..59b0791d9 100644 --- a/Sources/BluetoothGATT/GAPUUIDList.swift +++ b/Sources/BluetoothGATT/GAPUUIDList.swift @@ -7,6 +7,7 @@ // import Foundation +import Bluetooth /// GAP UUID List internal struct GAPUUIDList { @@ -14,7 +15,6 @@ internal struct GAPUUIDList { internal var uuids: [Element] internal init(uuids: [Element]) { - self.uuids = uuids } @@ -96,7 +96,7 @@ extension GAPUUIDList: Collection { internal protocol GAPUUIDElement: UnsafeDataConvertible { - init? (data: T) + init?(data: Data) init(littleEndian: Self) @@ -107,7 +107,7 @@ internal protocol GAPUUIDElement: UnsafeDataConvertible { extension UInt16: GAPUUIDElement { - init? (data: T) { + init?(data: Data) { guard data.count == MemoryLayout.size else { return nil } @@ -119,7 +119,7 @@ extension UInt16: GAPUUIDElement { extension UInt32: GAPUUIDElement { - init? (data: T) { + init?(data: Data) { guard data.count == MemoryLayout.size else { return nil } @@ -131,28 +131,4 @@ extension UInt32: GAPUUIDElement { } } -extension UInt128: GAPUUIDElement { - - init? (data: T) { - - guard data.count == MemoryLayout.size - else { return nil } - - self.init(bytes: (data[0], - data[1], - data[2], - data[3], - data[4], - data[5], - data[6], - data[7], - data[8], - data[9], - data[10], - data[11], - data[12], - data[13], - data[14], - data[15])) - } -} +extension Bluetooth.UInt128: GAPUUIDElement { } diff --git a/Sources/BluetoothGATT/GATTClient.swift b/Sources/BluetoothGATT/GATTClient.swift index d3cd6e6e5..7c9ccad0e 100755 --- a/Sources/BluetoothGATT/GATTClient.swift +++ b/Sources/BluetoothGATT/GATTClient.swift @@ -433,7 +433,7 @@ public actor GATTClient { startHandle: start, endHandle: end, attributeType: attributeType.rawValue, - attributeValue: uuid.littleEndian.data + attributeValue: Data(uuid.littleEndian) ) let response = try await send(request, response: ATTFindByTypeResponse.self) try await findByTypeResponse(response, &operation) @@ -766,7 +766,7 @@ public actor GATTClient { startHandle: operation.start, endHandle: operation.end, attributeType: operation.type.rawValue, - attributeValue: serviceUUID.littleEndian.data + attributeValue: Data(serviceUUID.littleEndian) ) let response = try await send(request, response: ATTFindByTypeResponse.self) try await findByTypeResponse(response, &operation) diff --git a/Sources/BluetoothGATT/GATTDatabase.swift b/Sources/BluetoothGATT/GATTDatabase.swift index 43ec8e9cc..701e6ee0a 100644 --- a/Sources/BluetoothGATT/GATTDatabase.swift +++ b/Sources/BluetoothGATT/GATTDatabase.swift @@ -472,7 +472,7 @@ internal extension GATTDatabase { return Attribute( handle: handle, uuid: serviceUUID, - value: self.uuid.littleEndian.data, + value: Data(self.uuid.littleEndian), permissions: [.read] ) } diff --git a/Sources/BluetoothGATT/GATTExternalReportReference.swift b/Sources/BluetoothGATT/GATTExternalReportReference.swift index 24bb764bd..1433b2de9 100644 --- a/Sources/BluetoothGATT/GATTExternalReportReference.swift +++ b/Sources/BluetoothGATT/GATTExternalReportReference.swift @@ -33,8 +33,7 @@ public struct GATTExternalReportReference: GATTDescriptor { } public var data: Data { - - return uuid.data + return Data(uuid) } public var descriptor: GATTAttribute.Descriptor {