Skip to content

Commit 636f590

Browse files
authored
Merge pull request #35 from zunda-pixel/update-bluetooth-library
update bluetooth library to v7.2.0
2 parents 28c1a5d + c83ab2a commit 636f590

File tree

4 files changed

+35
-35
lines changed

4 files changed

+35
-35
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var package = Package(
2929
dependencies: [
3030
.package(
3131
url: "https://github.com/PureSwift/Bluetooth.git",
32-
from: "7.1.0"
32+
from: "7.2.0"
3333
)
3434
],
3535
targets: [

Sources/DarwinGATT/DarwinDescriptor.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,27 @@ extension DarwinDescriptor {
5252
init?(_ descriptor: CBDescriptor) {
5353
let uuid = BluetoothUUID(descriptor.uuid)
5454
switch uuid {
55-
case .characteristicUserDescription:
55+
case BluetoothUUID.Descriptor.characteristicUserDescription:
5656
guard let userDescription = descriptor.value as? NSString
5757
else { return nil }
5858
self = .userDescription(userDescription)
59-
case .characteristicFormat:
59+
case BluetoothUUID.Descriptor.characteristicPresentationFormat:
6060
guard let data = descriptor.value as? NSData
6161
else { return nil }
6262
self = .format(data)
63-
case .characteristicExtendedProperties:
63+
case BluetoothUUID.Descriptor.characteristicExtendedProperties:
6464
guard let data = descriptor.value as? NSNumber
6565
else { return nil }
6666
self = .extendedProperties(data)
67-
case .characteristicAggregateFormat:
67+
case BluetoothUUID.Descriptor.characteristicAggregateFormat:
6868
guard let data = descriptor.value as? NSData
6969
else { return nil }
7070
self = .aggregateFormat(data)
71-
case .clientCharacteristicConfiguration:
71+
case BluetoothUUID.Descriptor.clientCharacteristicConfiguration:
7272
guard let data = descriptor.value as? NSNumber
7373
else { return nil }
7474
self = .clientConfiguration(data)
75-
case .serverCharacteristicConfiguration:
75+
case BluetoothUUID.Descriptor.serverCharacteristicConfiguration:
7676
guard let data = descriptor.value as? NSNumber
7777
else { return nil }
7878
self = .serverConfiguration(data)
@@ -84,12 +84,12 @@ extension DarwinDescriptor {
8484

8585
var uuid: BluetoothUUID {
8686
switch self {
87-
case .format: return .characteristicFormat
88-
case .userDescription: return .characteristicUserDescription
89-
case .extendedProperties: return .characteristicExtendedProperties
90-
case .aggregateFormat: return .characteristicAggregateFormat
91-
case .clientConfiguration: return .clientCharacteristicConfiguration
92-
case .serverConfiguration: return .serverCharacteristicConfiguration
87+
case .format: return BluetoothUUID.Descriptor.characteristicPresentationFormat
88+
case .userDescription: return BluetoothUUID.Descriptor.characteristicUserDescription
89+
case .extendedProperties: return BluetoothUUID.Descriptor.characteristicExtendedProperties
90+
case .aggregateFormat: return BluetoothUUID.Descriptor.characteristicAggregateFormat
91+
case .clientConfiguration: return BluetoothUUID.Descriptor.clientCharacteristicConfiguration
92+
case .serverConfiguration: return BluetoothUUID.Descriptor.serverCharacteristicConfiguration
9393
}
9494
}
9595

@@ -130,7 +130,7 @@ internal extension CBMutableDescriptor {
130130
/// Only the characteristic user description descriptor and the characteristic format descriptor
131131
/// are supported for descriptors for use in local Peripherals.
132132
static var supportedUUID: Set<BluetoothUUID> {
133-
return [.characteristicUserDescription, .characteristicFormat]
133+
return [BluetoothUUID.Descriptor.characteristicUserDescription, BluetoothUUID.Descriptor.characteristicPresentationFormat]
134134
}
135135

136136
convenience init?(_ descriptor: DarwinDescriptor) {
@@ -141,11 +141,11 @@ internal extension CBMutableDescriptor {
141141
convenience init?(uuid: BluetoothUUID, data: Data) {
142142
let descriptor: DarwinDescriptor
143143
switch uuid {
144-
case .characteristicUserDescription:
144+
case BluetoothUUID.Descriptor.characteristicUserDescription:
145145
guard let userDescription = String(data: data, encoding: .utf8)
146146
else { return nil }
147147
descriptor = .userDescription(userDescription as NSString)
148-
case .characteristicFormat:
148+
case BluetoothUUID.Descriptor.characteristicPresentationFormat:
149149
descriptor = .format(data as NSData)
150150
default:
151151
assert(Self.supportedUUID.contains(uuid) == false)

Sources/GATT/GATTClientConnection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ internal actor GATTClientConnection <Socket: L2CAPConnection> where Socket: Send
180180

181181
// Gatt Descriptors
182182
let descriptors: [GATTClient<Socket>.Descriptor]
183-
if gattCharacteristic.descriptors.values.contains(where: { $0.attribute.uuid == .clientCharacteristicConfiguration }) {
183+
if gattCharacteristic.descriptors.values.contains(where: { $0.attribute.uuid == BluetoothUUID.Descriptor.clientCharacteristicConfiguration }) {
184184
descriptors = Array(gattCharacteristic.descriptors.values.map { $0.attribute })
185185
} else {
186186
// fetch descriptors

Tests/GATTTests/GATTTests.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ final class GATTTests: XCTestCase {
139139
Ending Handle: 0xffff
140140
Attribute Group Type: 2800 (GATT Primary Service Declaration)
141141
*/
142-
(ATTReadByGroupTypeRequest(startHandle: 0x0001, endHandle: 0xffff, type: .primaryService),
142+
(ATTReadByGroupTypeRequest(startHandle: 0x0001, endHandle: 0xffff, type: BluetoothUUID.Declaration.primaryService),
143143
[0x10, 0x01, 0x00, 0xFF, 0xFF, 0x00, 0x28]),
144144
/**
145145
Read By Group Type Response
@@ -150,7 +150,7 @@ final class GATTTests: XCTestCase {
150150
(ATTReadByGroupTypeResponse(attributeData: [
151151
ATTReadByGroupTypeResponse.AttributeData(attributeHandle: 0x001,
152152
endGroupHandle: 0x0004,
153-
value: Data(BluetoothUUID.batteryService.littleEndian))
153+
value: Data(BluetoothUUID.Service.battery.littleEndian))
154154
])!,
155155
[0x11, 0x06, 0x01, 0x00, 0x04, 0x00, 0x0F, 0x18]),
156156
/**
@@ -160,7 +160,7 @@ final class GATTTests: XCTestCase {
160160
Ending Handle: 0xffff
161161
Attribute Group Type: 2800 (GATT Primary Service Declaration)
162162
*/
163-
(ATTReadByGroupTypeRequest(startHandle: 0x0005, endHandle: 0xffff, type: .primaryService),
163+
(ATTReadByGroupTypeRequest(startHandle: 0x0005, endHandle: 0xffff, type: BluetoothUUID.Declaration.primaryService),
164164
[0x10, 0x05, 0x00, 0xFF, 0xFF, 0x00, 0x28]),
165165
/**
166166
Error Response - Attribute Handle: 0x0005 - Error Code: 0x0A - Attribute Not Found
@@ -190,7 +190,7 @@ final class GATTTests: XCTestCase {
190190
]
191191

192192
let service = GATTAttribute<Data>.Service(
193-
uuid: .batteryService,
193+
uuid: BluetoothUUID.Service.battery,
194194
isPrimary: true,
195195
characteristics: characteristics
196196
)
@@ -211,7 +211,7 @@ final class GATTTests: XCTestCase {
211211
guard let foundService = services.first,
212212
services.count == 1
213213
else { XCTFail(); return }
214-
XCTAssertEqual(foundService.uuid, .batteryService)
214+
XCTAssertEqual(foundService.uuid, BluetoothUUID.Service.battery)
215215
XCTAssertEqual(foundService.isPrimary, true)
216216
let clientCache = await central.storage.connections.values.first?.connection.client.connection.socket.cache
217217
XCTAssertEqual(clientCache, mockData.client)
@@ -245,7 +245,7 @@ final class GATTTests: XCTestCase {
245245
]
246246

247247
let service = GATTAttribute<Data>.Service(
248-
uuid: .batteryService,
248+
uuid: BluetoothUUID.Service.battery,
249249
isPrimary: true,
250250
characteristics: characteristics
251251
)
@@ -266,13 +266,13 @@ final class GATTTests: XCTestCase {
266266
let currentValue = await peripheralDatabaseValue()
267267
XCTAssertEqual(currentValue, characteristics[0].value)
268268
peripheral.willWrite = {
269-
XCTAssertEqual($0.uuid, .batteryLevel)
269+
XCTAssertEqual($0.uuid, BluetoothUUID.Characteristic.batteryLevel)
270270
XCTAssertEqual($0.value, batteryLevel.data)
271271
XCTAssertEqual($0.newValue, newValue.data)
272272
return nil
273273
}
274274
peripheral.didWrite = {
275-
XCTAssertEqual($0.uuid, .batteryLevel)
275+
XCTAssertEqual($0.uuid, BluetoothUUID.Characteristic.batteryLevel)
276276
XCTAssertEqual($0.value, newValue.data)
277277
}
278278
},
@@ -283,13 +283,13 @@ final class GATTTests: XCTestCase {
283283
guard let foundService = services.first,
284284
services.count == 1
285285
else { XCTFail(); return }
286-
XCTAssertEqual(foundService.uuid, .batteryService)
286+
XCTAssertEqual(foundService.uuid, BluetoothUUID.Service.battery)
287287
XCTAssertEqual(foundService.isPrimary, true)
288288
let foundCharacteristics = try await central.discoverCharacteristics(for: foundService)
289289
guard let foundCharacteristic = foundCharacteristics.first,
290290
foundCharacteristics.count == 1
291291
else { XCTFail(); return }
292-
XCTAssertEqual(foundCharacteristic.uuid, .batteryLevel)
292+
XCTAssertEqual(foundCharacteristic.uuid, BluetoothUUID.Characteristic.batteryLevel)
293293
XCTAssertEqual(foundCharacteristic.properties, [.read, .write])
294294
// read value
295295
let characteristicData = try await central.readValue(for: foundCharacteristic)
@@ -323,7 +323,7 @@ final class GATTTests: XCTestCase {
323323
]
324324

325325
let service = GATTAttribute<Data>.Service(
326-
uuid: .batteryService,
326+
uuid: BluetoothUUID.Service.battery,
327327
isPrimary: true,
328328
characteristics: characteristics
329329
)
@@ -349,13 +349,13 @@ final class GATTTests: XCTestCase {
349349
guard let foundService = services.first,
350350
services.count == 1
351351
else { XCTFail(); return }
352-
XCTAssertEqual(foundService.uuid, .batteryService)
352+
XCTAssertEqual(foundService.uuid, BluetoothUUID.Service.battery)
353353
XCTAssertEqual(foundService.isPrimary, true)
354354
let foundCharacteristics = try await central.discoverCharacteristics(for: foundService)
355355
guard let foundCharacteristic = foundCharacteristics.first,
356356
foundCharacteristics.count == 1
357357
else { XCTFail(); return }
358-
XCTAssertEqual(foundCharacteristic.uuid, .batteryLevel)
358+
XCTAssertEqual(foundCharacteristic.uuid, BluetoothUUID.Characteristic.batteryLevel)
359359
XCTAssertEqual(foundCharacteristic.properties, [.read, .notify])
360360
// wait for notifications
361361
let stream = central.notify(for: foundCharacteristic)
@@ -388,7 +388,7 @@ final class GATTTests: XCTestCase {
388388
]
389389

390390
let service = GATTAttribute<Data>.Service(
391-
uuid: .batteryService,
391+
uuid: BluetoothUUID.Service.battery,
392392
isPrimary: true,
393393
characteristics: characteristics
394394
)
@@ -414,13 +414,13 @@ final class GATTTests: XCTestCase {
414414
guard let foundService = services.first,
415415
services.count == 1
416416
else { XCTFail(); return }
417-
XCTAssertEqual(foundService.uuid, .batteryService)
417+
XCTAssertEqual(foundService.uuid, BluetoothUUID.Service.battery)
418418
XCTAssertEqual(foundService.isPrimary, true)
419419
let foundCharacteristics = try await central.discoverCharacteristics(for: foundService)
420420
guard let foundCharacteristic = foundCharacteristics.first,
421421
foundCharacteristics.count == 1
422422
else { XCTFail(); return }
423-
XCTAssertEqual(foundCharacteristic.uuid, .batteryLevel)
423+
XCTAssertEqual(foundCharacteristic.uuid, BluetoothUUID.Characteristic.batteryLevel)
424424
XCTAssertEqual(foundCharacteristic.properties, [.read, .indicate])
425425
// wait for notifications
426426
let stream = central.notify(for: foundCharacteristic)
@@ -445,10 +445,10 @@ final class GATTTests: XCTestCase {
445445
GATTAttribute<Data>.Descriptor(uuid: BluetoothUUID(),
446446
value: Data("UInt128 Descriptor".utf8),
447447
permissions: [.read, .write]),
448-
GATTAttribute<Data>.Descriptor(uuid: .savantSystems,
448+
GATTAttribute<Data>.Descriptor(uuid: BluetoothUUID.Member.savantSystems,
449449
value: Data("Savant".utf8),
450450
permissions: [.read]),
451-
GATTAttribute<Data>.Descriptor(uuid: .savantSystems2,
451+
GATTAttribute<Data>.Descriptor(uuid: BluetoothUUID.Member.savantSystems2,
452452
value: Data("Savant2".utf8),
453453
permissions: [.write])
454454
]

0 commit comments

Comments
 (0)