Add error in connection updates (#89)

* Add error in connection updates

* implement windows

* Update changelog and Docs

* minor fix in connect()

* Add default timeout in connect

* Document new pair and connect API

* Fix Connect and Pair apis to throw proper errors and Improve logging

* remove import

* Rename PairingException and update Exception doc

* Update changelog

* Update comments

---------

Co-authored-by: Foti Dim <fdimanidis@gmail.com>
This commit is contained in:
Rohit Sangwan
2024-09-27 02:38:25 +05:30
committed by GitHub
parent f41aceaa0e
commit b77d0aaeb4
26 changed files with 851 additions and 698 deletions
+51 -38
View File
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v21.1.0), do not edit directly.
// Autogenerated from Pigeon (v22.4.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon
import Foundation
@@ -74,17 +74,19 @@ struct UniversalBleScanResult {
var name: String? = nil
var isPaired: Bool? = nil
var rssi: Int64? = nil
var manufacturerDataList: [UniversalManufacturerData?]? = nil
var services: [String?]? = nil
var manufacturerDataList: [UniversalManufacturerData]? = nil
var services: [String]? = nil
// swift-format-ignore: AlwaysUseLowerCamelCase
static func fromList(_ __pigeon_list: [Any?]) -> UniversalBleScanResult? {
let deviceId = __pigeon_list[0] as! String
let name: String? = nilOrValue(__pigeon_list[1])
let isPaired: Bool? = nilOrValue(__pigeon_list[2])
let rssi: Int64? = isNullish(__pigeon_list[3]) ? nil : (__pigeon_list[3] is Int64? ? __pigeon_list[3] as! Int64? : Int64(__pigeon_list[3] as! Int32))
let manufacturerDataList: [UniversalManufacturerData?]? = nilOrValue(__pigeon_list[4])
let services: [String?]? = nilOrValue(__pigeon_list[5])
static func fromList(_ pigeonVar_list: [Any?]) -> UniversalBleScanResult? {
let deviceId = pigeonVar_list[0] as! String
let name: String? = nilOrValue(pigeonVar_list[1])
let isPaired: Bool? = nilOrValue(pigeonVar_list[2])
let rssi: Int64? = nilOrValue(pigeonVar_list[3])
let manufacturerDataList: [UniversalManufacturerData]? = nilOrValue(pigeonVar_list[4])
let services: [String]? = nilOrValue(pigeonVar_list[5])
return UniversalBleScanResult(
deviceId: deviceId,
@@ -110,12 +112,14 @@ struct UniversalBleScanResult {
/// Generated class from Pigeon that represents data sent in messages.
struct UniversalBleService {
var uuid: String
var characteristics: [UniversalBleCharacteristic?]? = nil
var characteristics: [UniversalBleCharacteristic]? = nil
// swift-format-ignore: AlwaysUseLowerCamelCase
static func fromList(_ __pigeon_list: [Any?]) -> UniversalBleService? {
let uuid = __pigeon_list[0] as! String
let characteristics: [UniversalBleCharacteristic?]? = nilOrValue(__pigeon_list[1])
static func fromList(_ pigeonVar_list: [Any?]) -> UniversalBleService? {
let uuid = pigeonVar_list[0] as! String
let characteristics: [UniversalBleCharacteristic]? = nilOrValue(pigeonVar_list[1])
return UniversalBleService(
uuid: uuid,
@@ -133,12 +137,14 @@ struct UniversalBleService {
/// Generated class from Pigeon that represents data sent in messages.
struct UniversalBleCharacteristic {
var uuid: String
var properties: [Int64?]
var properties: [Int64]
// swift-format-ignore: AlwaysUseLowerCamelCase
static func fromList(_ __pigeon_list: [Any?]) -> UniversalBleCharacteristic? {
let uuid = __pigeon_list[0] as! String
let properties = __pigeon_list[1] as! [Int64?]
static func fromList(_ pigeonVar_list: [Any?]) -> UniversalBleCharacteristic? {
let uuid = pigeonVar_list[0] as! String
let properties = pigeonVar_list[1] as! [Int64]
return UniversalBleCharacteristic(
uuid: uuid,
@@ -157,15 +163,17 @@ struct UniversalBleCharacteristic {
///
/// Generated class from Pigeon that represents data sent in messages.
struct UniversalScanFilter {
var withServices: [String?]
var withNamePrefix: [String?]
var withManufacturerData: [UniversalManufacturerDataFilter?]
var withServices: [String]
var withNamePrefix: [String]
var withManufacturerData: [UniversalManufacturerDataFilter]
// swift-format-ignore: AlwaysUseLowerCamelCase
static func fromList(_ __pigeon_list: [Any?]) -> UniversalScanFilter? {
let withServices = __pigeon_list[0] as! [String?]
let withNamePrefix = __pigeon_list[1] as! [String?]
let withManufacturerData = __pigeon_list[2] as! [UniversalManufacturerDataFilter?]
static func fromList(_ pigeonVar_list: [Any?]) -> UniversalScanFilter? {
let withServices = pigeonVar_list[0] as! [String]
let withNamePrefix = pigeonVar_list[1] as! [String]
let withManufacturerData = pigeonVar_list[2] as! [UniversalManufacturerDataFilter]
return UniversalScanFilter(
withServices: withServices,
@@ -188,11 +196,13 @@ struct UniversalManufacturerDataFilter {
var data: FlutterStandardTypedData? = nil
var mask: FlutterStandardTypedData? = nil
// swift-format-ignore: AlwaysUseLowerCamelCase
static func fromList(_ __pigeon_list: [Any?]) -> UniversalManufacturerDataFilter? {
let companyIdentifier = __pigeon_list[0] is Int64 ? __pigeon_list[0] as! Int64 : Int64(__pigeon_list[0] as! Int32)
let data: FlutterStandardTypedData? = nilOrValue(__pigeon_list[1])
let mask: FlutterStandardTypedData? = nilOrValue(__pigeon_list[2])
static func fromList(_ pigeonVar_list: [Any?]) -> UniversalManufacturerDataFilter? {
let companyIdentifier = pigeonVar_list[0] as! Int64
let data: FlutterStandardTypedData? = nilOrValue(pigeonVar_list[1])
let mask: FlutterStandardTypedData? = nilOrValue(pigeonVar_list[2])
return UniversalManufacturerDataFilter(
companyIdentifier: companyIdentifier,
@@ -214,10 +224,12 @@ struct UniversalManufacturerData {
var companyIdentifier: Int64
var data: FlutterStandardTypedData
// swift-format-ignore: AlwaysUseLowerCamelCase
static func fromList(_ __pigeon_list: [Any?]) -> UniversalManufacturerData? {
let companyIdentifier = __pigeon_list[0] is Int64 ? __pigeon_list[0] as! Int64 : Int64(__pigeon_list[0] as! Int32)
let data = __pigeon_list[1] as! FlutterStandardTypedData
static func fromList(_ pigeonVar_list: [Any?]) -> UniversalManufacturerData? {
let companyIdentifier = pigeonVar_list[0] as! Int64
let data = pigeonVar_list[1] as! FlutterStandardTypedData
return UniversalManufacturerData(
companyIdentifier: companyIdentifier,
@@ -231,6 +243,7 @@ struct UniversalManufacturerData {
]
}
}
private class UniversalBlePigeonCodecReader: FlutterStandardReader {
override func readValue(ofType type: UInt8) -> Any? {
switch type {
@@ -416,7 +429,7 @@ class UniversalBlePlatformChannelSetup {
let deviceIdArg = args[0] as! String
let serviceArg = args[1] as! String
let characteristicArg = args[2] as! String
let bleInputPropertyArg = args[3] is Int64 ? args[3] as! Int64 : Int64(args[3] as! Int32)
let bleInputPropertyArg = args[3] as! Int64
api.setNotifiable(deviceId: deviceIdArg, service: serviceArg, characteristic: characteristicArg, bleInputProperty: bleInputPropertyArg) { result in
switch result {
case .success:
@@ -470,7 +483,7 @@ class UniversalBlePlatformChannelSetup {
requestMtuChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let deviceIdArg = args[0] as! String
let expectedMtuArg = args[1] is Int64 ? args[1] as! Int64 : Int64(args[1] as! Int32)
let expectedMtuArg = args[1] as! Int64
api.requestMtu(deviceId: deviceIdArg, expectedMtu: expectedMtuArg) { result in
switch result {
case .success(let res):
@@ -491,7 +504,7 @@ class UniversalBlePlatformChannelSetup {
let serviceArg = args[1] as! String
let characteristicArg = args[2] as! String
let valueArg = args[3] as! FlutterStandardTypedData
let bleOutputPropertyArg = args[4] is Int64 ? args[4] as! Int64 : Int64(args[4] as! Int32)
let bleOutputPropertyArg = args[4] as! Int64
api.writeValue(deviceId: deviceIdArg, service: serviceArg, characteristic: characteristicArg, value: valueArg, bleOutputProperty: bleOutputPropertyArg) { result in
switch result {
case .success:
@@ -595,7 +608,7 @@ protocol UniversalBleCallbackChannelProtocol {
func onPairStateChange(deviceId deviceIdArg: String, isPaired isPairedArg: Bool, error errorArg: String?, completion: @escaping (Result<Void, PigeonError>) -> Void)
func onScanResult(result resultArg: UniversalBleScanResult, completion: @escaping (Result<Void, PigeonError>) -> Void)
func onValueChanged(deviceId deviceIdArg: String, characteristicId characteristicIdArg: String, value valueArg: FlutterStandardTypedData, completion: @escaping (Result<Void, PigeonError>) -> Void)
func onConnectionChanged(deviceId deviceIdArg: String, connected connectedArg: Bool, completion: @escaping (Result<Void, PigeonError>) -> Void)
func onConnectionChanged(deviceId deviceIdArg: String, connected connectedArg: Bool, error errorArg: String?, completion: @escaping (Result<Void, PigeonError>) -> Void)
}
class UniversalBleCallbackChannel: UniversalBleCallbackChannelProtocol {
private let binaryMessenger: FlutterBinaryMessenger
@@ -679,10 +692,10 @@ class UniversalBleCallbackChannel: UniversalBleCallbackChannelProtocol {
}
}
}
func onConnectionChanged(deviceId deviceIdArg: String, connected connectedArg: Bool, completion: @escaping (Result<Void, PigeonError>) -> Void) {
func onConnectionChanged(deviceId deviceIdArg: String, connected connectedArg: Bool, error errorArg: String?, completion: @escaping (Result<Void, PigeonError>) -> Void) {
let channelName: String = "dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onConnectionChanged\(messageChannelSuffix)"
let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec)
channel.sendMessage([deviceIdArg, connectedArg] as [Any?]) { response in
channel.sendMessage([deviceIdArg, connectedArg, errorArg] as [Any?]) { response in
guard let listResponse = response as? [Any?] else {
completion(.failure(createConnectionError(withChannelName: channelName)))
return
+2 -2
View File
@@ -104,11 +104,11 @@ extension CBManagerState {
}
extension Error {
func toFlutterError() -> FlutterError {
func toPigeonError() -> PigeonError {
let nsError = self as NSError
let errorCode: String = .init(nsError.code)
let errorDescription: String = nsError.localizedDescription
return FlutterError(code: errorCode, message: errorDescription, details: nil)
return PigeonError(code: errorCode, message: errorDescription, details: nil)
}
}
+34 -36
View File
@@ -55,7 +55,7 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
}
func enableBluetooth(completion: @escaping (Result<Bool, Error>) -> Void) {
completion(Result.failure(FlutterError(code: "NotSupported", message: nil, details: nil)))
completion(Result.failure(PigeonError(code: "NotSupported", message: nil, details: nil)))
}
func startScan(filter: UniversalScanFilter?) throws {
@@ -117,7 +117,7 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
characteristicReadFutures.removeAll { future in
if future.deviceId == deviceId {
future.result(
Result.failure(FlutterError(code: "DeviceDisconnected", message: "Device Disconnected", details: nil))
Result.failure(PigeonError(code: "DeviceDisconnected", message: "Device Disconnected", details: nil))
)
return true
}
@@ -126,7 +126,7 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
characteristicWriteFutures.removeAll { future in
if future.deviceId == deviceId {
future.result(
Result.failure(FlutterError(code: "DeviceDisconnected", message: "Device Disconnected", details: nil))
Result.failure(PigeonError(code: "DeviceDisconnected", message: "Device Disconnected", details: nil))
)
return true
}
@@ -135,7 +135,7 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
characteristicNotifyFutures.removeAll { future in
if future.deviceId == deviceId {
future.result(
Result.failure(FlutterError(code: "DeviceDisconnected", message: "Device Disconnected", details: nil))
Result.failure(PigeonError(code: "DeviceDisconnected", message: "Device Disconnected", details: nil))
)
return true
}
@@ -144,7 +144,7 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
discoverServicesFutures.removeAll { future in
if future.deviceId == deviceId {
future.result(
Result.failure(FlutterError(code: "DeviceDisconnected", message: "Device Disconnected", details: nil))
Result.failure(PigeonError(code: "DeviceDisconnected", message: "Device Disconnected", details: nil))
)
return true
}
@@ -156,7 +156,7 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
func discoverServices(deviceId: String, completion: @escaping (Result<[UniversalBleService], Error>) -> Void) {
guard let peripheral = discoveredPeripherals[deviceId] else {
completion(
Result.failure(FlutterError(code: "IllegalArgument", message: "Unknown deviceId:\(self)", details: nil))
Result.failure(PigeonError(code: "IllegalArgument", message: "Unknown deviceId:\(self)", details: nil))
)
return
}
@@ -193,22 +193,22 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
func setNotifiable(deviceId: String, service: String, characteristic: String, bleInputProperty: Int64, completion: @escaping (Result<Void, any Error>) -> Void) {
guard let peripheral = discoveredPeripherals[deviceId] else {
completion(Result.failure(FlutterError(code: "IllegalArgument", message: "Unknown deviceId:\(self)", details: nil)))
completion(Result.failure(PigeonError(code: "IllegalArgument", message: "Unknown deviceId:\(self)", details: nil)))
return
}
guard let gattCharacteristic = peripheral.getCharacteristic(characteristic, of: service) else {
completion(Result.failure(FlutterError(code: "IllegalArgument", message: "Unknown characteristic:\(characteristic)", details: nil)))
completion(Result.failure(PigeonError(code: "IllegalArgument", message: "Unknown characteristic:\(characteristic)", details: nil)))
return
}
if bleInputProperty == BleInputProperty.notification.rawValue && !gattCharacteristic.properties.contains(.notify) {
completion(Result.failure(FlutterError(code: "InvalidAction", message: "Characteristic does not support notify", details: nil)))
completion(Result.failure(PigeonError(code: "InvalidAction", message: "Characteristic does not support notify", details: nil)))
return
}
if bleInputProperty == BleInputProperty.indication.rawValue && !gattCharacteristic.properties.contains(.indicate) {
completion(Result.failure(FlutterError(code: "InvalidAction", message: "Characteristic does not support indicate", details: nil)))
completion(Result.failure(PigeonError(code: "InvalidAction", message: "Characteristic does not support indicate", details: nil)))
return
}
@@ -219,15 +219,15 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
func readValue(deviceId: String, service: String, characteristic: String, completion: @escaping (Result<FlutterStandardTypedData, Error>) -> Void) {
guard let peripheral = discoveredPeripherals[deviceId] else {
completion(Result.failure(FlutterError(code: "IllegalArgument", message: "Unknown deviceId:\(self)", details: nil)))
completion(Result.failure(PigeonError(code: "IllegalArgument", message: "Unknown deviceId:\(self)", details: nil)))
return
}
guard let gattCharacteristic = peripheral.getCharacteristic(characteristic, of: service) else {
completion(Result.failure(FlutterError(code: "IllegalArgument", message: "Unknown characteristic:\(characteristic)", details: nil)))
completion(Result.failure(PigeonError(code: "IllegalArgument", message: "Unknown characteristic:\(characteristic)", details: nil)))
return
}
if !gattCharacteristic.properties.contains(.read) {
completion(Result.failure(FlutterError(code: "InvalidAction", message: "Characteristic does not support read", details: nil)))
completion(Result.failure(PigeonError(code: "InvalidAction", message: "Characteristic does not support read", details: nil)))
return
}
peripheral.readValue(for: gattCharacteristic)
@@ -236,11 +236,11 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
func writeValue(deviceId: String, service: String, characteristic: String, value: FlutterStandardTypedData, bleOutputProperty: Int64, completion: @escaping (Result<Void, Error>) -> Void) {
guard let peripheral = discoveredPeripherals[deviceId] else {
completion(Result.failure(FlutterError(code: "IllegalArgument", message: "Unknown deviceId:\(self)", details: nil)))
completion(Result.failure(PigeonError(code: "IllegalArgument", message: "Unknown deviceId:\(self)", details: nil)))
return
}
guard let gattCharacteristic = peripheral.getCharacteristic(characteristic, of: service) else {
completion(Result.failure(FlutterError(code: "IllegalArgument", message: "Unknown characteristic:\(characteristic)", details: nil)))
completion(Result.failure(PigeonError(code: "IllegalArgument", message: "Unknown characteristic:\(characteristic)", details: nil)))
return
}
@@ -248,12 +248,12 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
if type == CBCharacteristicWriteType.withResponse {
if !gattCharacteristic.properties.contains(.write) {
completion(Result.failure(FlutterError(code: "InvalidAction", message: "Characteristic does not support write withResponse", details: nil)))
completion(Result.failure(PigeonError(code: "InvalidAction", message: "Characteristic does not support write withResponse", details: nil)))
return
}
} else if type == CBCharacteristicWriteType.withoutResponse {
if !gattCharacteristic.properties.contains(.writeWithoutResponse) {
completion(Result.failure(FlutterError(code: "InvalidAction", message: "Characteristic does not support write withoutResponse", details: nil)))
completion(Result.failure(PigeonError(code: "InvalidAction", message: "Characteristic does not support write withoutResponse", details: nil)))
return
}
}
@@ -269,7 +269,7 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
func requestMtu(deviceId: String, expectedMtu _: Int64, completion: @escaping (Result<Int64, Error>) -> Void) {
guard let peripheral = discoveredPeripherals[deviceId] else {
completion(Result.failure(FlutterError(code: "IllegalArgument", message: "Unknown deviceId:\(self)", details: nil)))
completion(Result.failure(PigeonError(code: "IllegalArgument", message: "Unknown deviceId:\(self)", details: nil)))
return
}
let mtu = peripheral.maximumWriteValueLength(for: CBCharacteristicWriteType.withoutResponse)
@@ -279,15 +279,15 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
}
func isPaired(deviceId _: String, completion: @escaping (Result<Bool, Error>) -> Void) {
completion(Result.failure(FlutterError(code: "NotSupported", message: nil, details: nil)))
completion(Result.failure(PigeonError(code: "NotSupported", message: nil, details: nil)))
}
func pair(deviceId _: String, completion: @escaping (Result<Bool, Error>) -> Void) {
completion(Result.failure(FlutterError(code: "Implemented in Dart", message: nil, details: nil)))
completion(Result.failure(PigeonError(code: "Implemented in Dart", message: nil, details: nil)))
}
func unPair(deviceId _: String) throws {
throw FlutterError(code: "NotSupported", message: nil, details: nil)
throw PigeonError(code: "NotSupported", message: nil, details: nil)
}
func getSystemDevices(withServices: [String], completion: @escaping (Result<[UniversalBleScanResult], Error>) -> Void) {
@@ -345,17 +345,17 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
}
public func centralManager(_: CBCentralManager, didConnect peripheral: CBPeripheral) {
callbackChannel.onConnectionChanged(deviceId: peripheral.uuid.uuidString, connected: true) { _ in }
callbackChannel.onConnectionChanged(deviceId: peripheral.uuid.uuidString, connected: true, error: nil) { _ in }
}
public func centralManager(_: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error _: Error?) {
callbackChannel.onConnectionChanged(deviceId: peripheral.uuid.uuidString, connected: false) { _ in }
// Cleanup on disconnect
callbackChannel.onConnectionChanged(deviceId: peripheral.uuid.uuidString, connected: false, error: nil) { _ in }
cleanUpConnection(deviceId: peripheral.uuid.uuidString)
}
public func centralManager(_: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Error?) {
print("Failed to connect: \(peripheral.uuid.uuidString): \(String(describing: error))")
callbackChannel.onConnectionChanged(deviceId: peripheral.uuid.uuidString, connected: false, error: error?.localizedDescription) { _ in }
cleanUpConnection(deviceId: peripheral.uuid.uuidString)
}
public func peripheral(_ peripheral: CBPeripheral, didDiscoverServices _: Error?) {
@@ -397,8 +397,8 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
public func peripheral(_ peripheral: CBPeripheral, didWriteValueFor characteristic: CBCharacteristic, error: Error?) {
characteristicWriteFutures.removeAll { future in
if future.deviceId == peripheral.uuid.uuidString && future.characteristicId == characteristic.uuid.uuidStr && future.serviceId == characteristic.service?.uuid.uuidStr {
if let flutterError = error?.toFlutterError() {
future.result(Result.failure(flutterError))
if let pigeonError = error?.toPigeonError() {
future.result(Result.failure(pigeonError))
} else {
future.result(Result.success({}()))
}
@@ -411,8 +411,8 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
public func peripheral(_ peripheral: CBPeripheral, didUpdateNotificationStateFor characteristic: CBCharacteristic, error: Error?) {
characteristicNotifyFutures.removeAll { future in
if future.deviceId == peripheral.uuid.uuidString && future.characteristicId == characteristic.uuid.uuidStr && future.serviceId == characteristic.service?.uuid.uuidStr {
if let flutterError = error?.toFlutterError() {
future.result(Result.failure(flutterError))
if let pigeonError = error?.toPigeonError() {
future.result(Result.failure(pigeonError))
} else {
future.result(Result.success({}()))
}
@@ -437,13 +437,13 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
// Update futures for readValue
characteristicReadFutures.removeAll { future in
if future.deviceId == peripheral.uuid.uuidString && future.characteristicId == characteristic.uuid.uuidStr && future.serviceId == characteristic.service?.uuid.uuidStr {
if let flutterError = error?.toFlutterError() {
future.result(Result.failure(flutterError))
if let pigeonError = error?.toPigeonError() {
future.result(Result.failure(pigeonError))
} else {
if let characteristicValue = characteristic.value {
future.result(Result.success(FlutterStandardTypedData(bytes: characteristicValue)))
} else {
future.result(Result.failure(FlutterError(code: "ReadFailed", message: "No value", details: nil)))
future.result(Result.failure(PigeonError(code: "ReadFailed", message: "No value", details: nil)))
}
}
return true
@@ -456,7 +456,7 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral
extension String {
func getPeripheral() throws -> CBPeripheral {
guard let peripheral = discoveredPeripherals[self] else {
throw FlutterError(code: "IllegalArgument", message: "Unknown deviceId:\(self)", details: nil)
throw PigeonError(code: "IllegalArgument", message: "Unknown deviceId:\(self)", details: nil)
}
return peripheral
}
@@ -466,11 +466,9 @@ extension [String] {
func toCBUUID() throws -> [CBUUID] {
return try compactMap { serviceUUID in
guard UUID(uuidString: serviceUUID.validFullUUID) != nil else {
throw FlutterError(code: "IllegalArgument", message: "Invalid service UUID:\(serviceUUID)", details: nil)
throw PigeonError(code: "IllegalArgument", message: "Invalid service UUID:\(serviceUUID)", details: nil)
}
return CBUUID(string: serviceUUID)
}
}
}
extension FlutterError: Error {}