Skip to content

Commit

Permalink
Merge pull request #2 from teufelaudio/Xcode13
Browse files Browse the repository at this point in the history
Support Xcode 13
  • Loading branch information
luizmb authored Sep 27, 2021
2 parents ff65967 + 79a8b6f commit 347f336
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ struct CoreBluetoothCharacteristic: Identifiable {
}

extension CoreBluetoothCharacteristic: BluetoothCharacteristic {
var service: BluetoothService { CoreBluetoothService(service: characteristic.service) }
#if swift(>=5.5) && !os(macOS)
var service: BluetoothService? { characteristic.service.map(CoreBluetoothService.init) }
#else
var service: BluetoothService? { CoreBluetoothService(service: characteristic.service) }
#endif
var properties: CBCharacteristicProperties { characteristic.properties }
var value: Data? { characteristic.value }
var descriptors: [BluetoothDescriptor]? { characteristic.descriptors?.map(CoreBluetoothDescriptor.init) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ struct CoreBluetoothDescriptor: Identifiable {
}

extension CoreBluetoothDescriptor: BluetoothDescriptor {
var characteristic: BluetoothCharacteristic { CoreBluetoothCharacteristic(characteristic: descriptor.characteristic) }
#if swift(>=5.5) && !os(macOS)
var characteristic: BluetoothCharacteristic? { descriptor.characteristic.map(CoreBluetoothCharacteristic.init) }
#else
var characteristic: BluetoothCharacteristic? { CoreBluetoothCharacteristic(characteristic: descriptor.characteristic) }
#endif
var value: Any? { descriptor.value }
}
6 changes: 5 additions & 1 deletion Sources/CombineBluetooth/Internal/CoreBluetoothService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ struct CoreBluetoothService: Identifiable {
}

extension CoreBluetoothService: BluetoothService {
var peripheral: UUID { service.peripheral.identifier }
#if swift(>=5.5) && !os(macOS)
var peripheral: UUID? { service.peripheral?.identifier }
#else
var peripheral: UUID? { service.peripheral.identifier }
#endif
var isPrimary: Bool { service.isPrimary }
var includedServices: [BluetoothService]? { service.includedServices?.map(CoreBluetoothService.init) }
var characteristics: [BluetoothCharacteristic]? { service.characteristics?.map(CoreBluetoothCharacteristic.init) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CoreBluetooth
// sourcery: AutoMockable
public protocol BluetoothCharacteristic {
var id: CBUUID { get }
var service: BluetoothService { get }
var service: BluetoothService? { get }
var properties: CBCharacteristicProperties { get }
var value: Data? { get }
var descriptors: [BluetoothDescriptor]? { get }
Expand Down
2 changes: 1 addition & 1 deletion Sources/CombineBluetooth/Models/BluetoothDescriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import CoreBluetooth
// sourcery: AutoMockable
public protocol BluetoothDescriptor {
var id: CBUUID { get }
var characteristic: BluetoothCharacteristic { get }
var characteristic: BluetoothCharacteristic? { get }
var value: Any? { get }
}
2 changes: 1 addition & 1 deletion Sources/CombineBluetooth/Models/BluetoothService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CoreBluetooth
// sourcery: AutoMockable
public protocol BluetoothService {
var id: CBUUID { get }
var peripheral: UUID { get }
var peripheral: UUID? { get }
var isPrimary: Bool { get }
var includedServices: [BluetoothService]? { get }
var characteristics: [BluetoothCharacteristic]? { get }
Expand Down

0 comments on commit 347f336

Please sign in to comment.