diff --git a/android/src/main/kotlin/com/navideck/universal_ble/UniversalBle.g.kt b/android/src/main/kotlin/com/navideck/universal_ble/UniversalBle.g.kt index aa93c1a..dfcf243 100644 --- a/android/src/main/kotlin/com/navideck/universal_ble/UniversalBle.g.kt +++ b/android/src/main/kotlin/com/navideck/universal_ble/UniversalBle.g.kt @@ -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 @file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") @@ -53,19 +53,18 @@ data class UniversalBleScanResult ( val name: String? = null, val isPaired: Boolean? = null, val rssi: Long? = null, - val manufacturerDataList: List? = null, - val services: List? = null - -) { + val manufacturerDataList: List? = null, + val services: List? = null +) + { companion object { - @Suppress("LocalVariableName") - fun fromList(__pigeon_list: List): UniversalBleScanResult { - val deviceId = __pigeon_list[0] as String - val name = __pigeon_list[1] as String? - val isPaired = __pigeon_list[2] as Boolean? - val rssi = __pigeon_list[3].let { num -> if (num is Int) num.toLong() else num as Long? } - val manufacturerDataList = __pigeon_list[4] as List? - val services = __pigeon_list[5] as List? + fun fromList(pigeonVar_list: List): UniversalBleScanResult { + val deviceId = pigeonVar_list[0] as String + val name = pigeonVar_list[1] as String? + val isPaired = pigeonVar_list[2] as Boolean? + val rssi = pigeonVar_list[3] as Long? + val manufacturerDataList = pigeonVar_list[4] as List? + val services = pigeonVar_list[5] as List? return UniversalBleScanResult(deviceId, name, isPaired, rssi, manufacturerDataList, services) } } @@ -84,14 +83,13 @@ data class UniversalBleScanResult ( /** Generated class from Pigeon that represents data sent in messages. */ data class UniversalBleService ( val uuid: String, - val characteristics: List? = null - -) { + val characteristics: List? = null +) + { companion object { - @Suppress("LocalVariableName") - fun fromList(__pigeon_list: List): UniversalBleService { - val uuid = __pigeon_list[0] as String - val characteristics = __pigeon_list[1] as List? + fun fromList(pigeonVar_list: List): UniversalBleService { + val uuid = pigeonVar_list[0] as String + val characteristics = pigeonVar_list[1] as List? return UniversalBleService(uuid, characteristics) } } @@ -106,14 +104,13 @@ data class UniversalBleService ( /** Generated class from Pigeon that represents data sent in messages. */ data class UniversalBleCharacteristic ( val uuid: String, - val properties: List - -) { + val properties: List +) + { companion object { - @Suppress("LocalVariableName") - fun fromList(__pigeon_list: List): UniversalBleCharacteristic { - val uuid = __pigeon_list[0] as String - val properties = __pigeon_list[1] as List + fun fromList(pigeonVar_list: List): UniversalBleCharacteristic { + val uuid = pigeonVar_list[0] as String + val properties = pigeonVar_list[1] as List return UniversalBleCharacteristic(uuid, properties) } } @@ -131,17 +128,16 @@ data class UniversalBleCharacteristic ( * Generated class from Pigeon that represents data sent in messages. */ data class UniversalScanFilter ( - val withServices: List, - val withNamePrefix: List, - val withManufacturerData: List - -) { + val withServices: List, + val withNamePrefix: List, + val withManufacturerData: List +) + { companion object { - @Suppress("LocalVariableName") - fun fromList(__pigeon_list: List): UniversalScanFilter { - val withServices = __pigeon_list[0] as List - val withNamePrefix = __pigeon_list[1] as List - val withManufacturerData = __pigeon_list[2] as List + fun fromList(pigeonVar_list: List): UniversalScanFilter { + val withServices = pigeonVar_list[0] as List + val withNamePrefix = pigeonVar_list[1] as List + val withManufacturerData = pigeonVar_list[2] as List return UniversalScanFilter(withServices, withNamePrefix, withManufacturerData) } } @@ -159,14 +155,13 @@ data class UniversalManufacturerDataFilter ( val companyIdentifier: Long, val data: ByteArray? = null, val mask: ByteArray? = null - -) { +) + { companion object { - @Suppress("LocalVariableName") - fun fromList(__pigeon_list: List): UniversalManufacturerDataFilter { - val companyIdentifier = __pigeon_list[0].let { num -> if (num is Int) num.toLong() else num as Long } - val data = __pigeon_list[1] as ByteArray? - val mask = __pigeon_list[2] as ByteArray? + fun fromList(pigeonVar_list: List): UniversalManufacturerDataFilter { + val companyIdentifier = pigeonVar_list[0] as Long + val data = pigeonVar_list[1] as ByteArray? + val mask = pigeonVar_list[2] as ByteArray? return UniversalManufacturerDataFilter(companyIdentifier, data, mask) } } @@ -183,13 +178,12 @@ data class UniversalManufacturerDataFilter ( data class UniversalManufacturerData ( val companyIdentifier: Long, val data: ByteArray - -) { +) + { companion object { - @Suppress("LocalVariableName") - fun fromList(__pigeon_list: List): UniversalManufacturerData { - val companyIdentifier = __pigeon_list[0].let { num -> if (num is Int) num.toLong() else num as Long } - val data = __pigeon_list[1] as ByteArray + fun fromList(pigeonVar_list: List): UniversalManufacturerData { + val companyIdentifier = pigeonVar_list[0] as Long + val data = pigeonVar_list[1] as ByteArray return UniversalManufacturerData(companyIdentifier, data) } } @@ -200,7 +194,7 @@ data class UniversalManufacturerData ( ) } } -private object UniversalBlePigeonCodec : StandardMessageCodec() { +private open class UniversalBlePigeonCodec : StandardMessageCodec() { override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { return when (type) { 129.toByte() -> { @@ -294,7 +288,7 @@ interface UniversalBlePlatformChannel { companion object { /** The codec used by UniversalBlePlatformChannel. */ val codec: MessageCodec by lazy { - UniversalBlePigeonCodec + UniversalBlePigeonCodec() } /** Sets up an instance of `UniversalBlePlatformChannel` to handle messages through the `binaryMessenger`. */ @JvmOverloads @@ -414,7 +408,7 @@ interface UniversalBlePlatformChannel { val deviceIdArg = args[0] as String val serviceArg = args[1] as String val characteristicArg = args[2] as String - val bleInputPropertyArg = args[3].let { num -> if (num is Int) num.toLong() else num as Long } + val bleInputPropertyArg = args[3] as Long api.setNotifiable(deviceIdArg, serviceArg, characteristicArg, bleInputPropertyArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { @@ -476,7 +470,7 @@ interface UniversalBlePlatformChannel { channel.setMessageHandler { message, reply -> val args = message as List val deviceIdArg = args[0] as String - val expectedMtuArg = args[1].let { num -> if (num is Int) num.toLong() else num as Long } + val expectedMtuArg = args[1] as Long api.requestMtu(deviceIdArg, expectedMtuArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { @@ -500,7 +494,7 @@ interface UniversalBlePlatformChannel { val serviceArg = args[1] as String val characteristicArg = args[2] as String val valueArg = args[3] as ByteArray - val bleOutputPropertyArg = args[4].let { num -> if (num is Int) num.toLong() else num as Long } + val bleOutputPropertyArg = args[4] as Long api.writeValue(deviceIdArg, serviceArg, characteristicArg, valueArg, bleOutputPropertyArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { @@ -621,7 +615,7 @@ class UniversalBleCallbackChannel(private val binaryMessenger: BinaryMessenger, companion object { /** The codec used by UniversalBleCallbackChannel. */ val codec: MessageCodec by lazy { - UniversalBlePigeonCodec + UniversalBlePigeonCodec() } } fun onAvailabilityChanged(stateArg: Long, callback: (Result) -> Unit) @@ -692,12 +686,12 @@ class UniversalBleCallbackChannel(private val binaryMessenger: BinaryMessenger, } } } - fun onConnectionChanged(deviceIdArg: String, connectedArg: Boolean, callback: (Result) -> Unit) + fun onConnectionChanged(deviceIdArg: String, connectedArg: Boolean, errorArg: String?, callback: (Result) -> Unit) { val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else "" val channelName = "dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onConnectionChanged$separatedMessageChannelSuffix" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) - channel.send(listOf(deviceIdArg, connectedArg)) { + channel.send(listOf(deviceIdArg, connectedArg, errorArg)) { if (it is List<*>) { if (it.size > 1) { callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) diff --git a/android/src/main/kotlin/com/navideck/universal_ble/UniversalBleHelper.kt b/android/src/main/kotlin/com/navideck/universal_ble/UniversalBleHelper.kt index a0717c8..592b77e 100644 --- a/android/src/main/kotlin/com/navideck/universal_ble/UniversalBleHelper.kt +++ b/android/src/main/kotlin/com/navideck/universal_ble/UniversalBleHelper.kt @@ -245,6 +245,82 @@ val DeviceDisconnectedError: FlutterError = FlutterError( null ) +fun Int.parseHciErrorCode(): String? { + return when (this) { + BluetoothGatt.GATT_SUCCESS -> null + 0x01 -> "Unknown HCI Command" + 0x02 -> "Unknown Connection Identifier" + 0x03 -> "Hardware Failure" + 0x04 -> "Page Timeout" + 0x05 -> "Authentication Failure" + 0x06 -> "PIN or Key Missing" + 0x07 -> "Memory Capacity Exceeded" + 0x08 -> "Connection Timeout" + 0x09 -> "Connection Limit Exceeded" + 0x0A -> "Synchronous Connection Limit To A Device Exceeded" + 0x0B -> "Connection Already Exists" + 0x0C -> "Command Disallowed" + 0x0D -> "Connection Rejected due to Limited Resources" + 0x0E -> "Connection Rejected Due To Security Reasons" + 0x0F -> "Connection Rejected due to Unacceptable BD_ADDR" + 0x10 -> "Connection Accept Timeout Exceeded" + 0x11 -> "Unsupported Feature or Parameter Value" + 0x12 -> "Invalid HCI Command Parameters" + 0x13 -> "Remote User Terminated Connection" + 0x14 -> "Remote Device Terminated Connection due to Low Resources" + 0x15 -> "Remote Device Terminated Connection due to Power Off" + 0x16 -> "Connection Terminated By Local Host" + 0x17 -> "Repeated Attempts" + 0x18 -> "Pairing Not Allowed" + 0x19 -> "Unknown LMP PDU" + 0x1A -> "Unsupported Remote Feature / Unsupported LMP Feature" + 0x1B -> "SCO Offset Rejected" + 0x1C -> "SCO Interval Rejected" + 0x1D -> "SCO Air Mode Rejected" + 0x1E -> "Invalid LMP Parameters / Invalid LL Parameters" + 0x1F -> "Unspecified Error" + 0x20 -> "Unsupported LMP Parameter Value / Unsupported LL Parameter Value" + 0x21 -> "Role Change Not Allowed" + 0x22 -> "LMP Response Timeout / LL Response Timeout" + 0x23 -> "LMP Error Transaction Collision / LL Procedure Collision" + 0x24 -> "LMP PDU Not Allowed" + 0x25 -> "Encryption Mode Not Acceptable" + 0x26 -> "Link Key cannot be Changed" + 0x27 -> "Requested QoS Not Supported" + 0x28 -> "Instant Passed" + 0x29 -> "Pairing With Unit Key Not Supported" + 0x2A -> "Different Transaction Collision" + 0x2B -> "Reserved for future use" + 0x2C -> "QoS Unacceptable Parameter" + 0x2D -> "QoS Rejected" + 0x2E -> "Channel Classification Not Supported" + 0x2F -> "Insufficient Security" + 0x30 -> "Parameter Out Of Mandatory Range" + 0x31 -> "Reserved for future use" + 0x32 -> "Role Switch Pending" + 0x33 -> "Reserved for future use" + 0x34 -> "Reserved Slot Violation" + 0x35 -> "Role Switch Failed" + 0x36 -> "Extended Inquiry Response Too Large" + 0x37 -> "Secure Simple Pairing Not Supported By Host" + 0x38 -> "Host Busy - Pairing" + 0x39 -> "Connection Rejected due to No Suitable Channel Found" + 0x3A -> "Controller Busy" + 0x3B -> "Unacceptable Connection Parameters" + 0x3C -> "Advertising Timeout" + 0x3D -> "Connection Terminated due to MIC Failure" + 0x3E -> "Connection Failed to be Established / Synchronization Timeout" + 0x3F -> "MAC Connection Failed" + 0x40 -> "Coarse Clock Adjustment Rejected but Will Try to Adjust Using Clock Dragging" + 0x41 -> "Type0 Submap Not Defined" + 0x42 -> "Unknown Advertising Identifier" + 0x43 -> "Limit Reached" + 0x44 -> "Operation Cancelled by Host" + 0x45 -> "Packet Too Long" + else -> "Unknown Error $this" + } +} + // Future result classes class DiscoverServicesFuture( val deviceId: String, diff --git a/android/src/main/kotlin/com/navideck/universal_ble/UniversalBlePlugin.kt b/android/src/main/kotlin/com/navideck/universal_ble/UniversalBlePlugin.kt index cc3a977..7688129 100644 --- a/android/src/main/kotlin/com/navideck/universal_ble/UniversalBlePlugin.kt +++ b/android/src/main/kotlin/com/navideck/universal_ble/UniversalBlePlugin.kt @@ -162,7 +162,7 @@ class UniversalBlePlugin : UniversalBlePlatformChannel, BluetoothGattCallback(), if (currentState == BluetoothGatt.STATE_CONNECTED) { Log.e(TAG, "$deviceId Already connected") mainThreadHandler?.post { - callbackChannel?.onConnectionChanged(deviceId, true) {} + callbackChannel?.onConnectionChanged(deviceId, true, null) {} } return } else if (currentState == BluetoothGatt.STATE_CONNECTING) { @@ -864,19 +864,22 @@ class UniversalBlePlugin : UniversalBlePlatformChannel, BluetoothGattCallback(), override fun onConnectionStateChange(gatt: BluetoothGatt, status: Int, newState: Int) { devicesStateMap[gatt.device.address] = newState - Log.d(TAG, "onConnectionStateChange-> Status: ${status}, NewState: $newState") + Log.d( + TAG, + "onConnectionStateChange-> Status: $status ${status.parseHciErrorCode()}, NewState: $newState" + ) if (newState == BluetoothGatt.STATE_CONNECTED) { mainThreadHandler?.post { callbackChannel?.onConnectionChanged( - gatt.device.address, true + gatt.device.address, true, status.parseHciErrorCode() ) {} } } else if (newState == BluetoothGatt.STATE_DISCONNECTED) { cleanConnection(gatt) mainThreadHandler?.post { callbackChannel?.onConnectionChanged( - gatt.device.address, false + gatt.device.address, false, status.parseHciErrorCode() ) {} } } diff --git a/darwin/Classes/UniversalBle.g.swift b/darwin/Classes/UniversalBle.g.swift index 6f134e7..3bacd2f 100644 --- a/darwin/Classes/UniversalBle.g.swift +++ b/darwin/Classes/UniversalBle.g.swift @@ -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) func onScanResult(result resultArg: UniversalBleScanResult, completion: @escaping (Result) -> Void) func onValueChanged(deviceId deviceIdArg: String, characteristicId characteristicIdArg: String, value valueArg: FlutterStandardTypedData, completion: @escaping (Result) -> Void) - func onConnectionChanged(deviceId deviceIdArg: String, connected connectedArg: Bool, completion: @escaping (Result) -> Void) + func onConnectionChanged(deviceId deviceIdArg: String, connected connectedArg: Bool, error errorArg: String?, completion: @escaping (Result) -> 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) { + func onConnectionChanged(deviceId deviceIdArg: String, connected connectedArg: Bool, error errorArg: String?, completion: @escaping (Result) -> 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 diff --git a/darwin/Classes/UniversalBleHelper.swift b/darwin/Classes/UniversalBleHelper.swift index 9090f97..3b6cb8f 100644 --- a/darwin/Classes/UniversalBleHelper.swift +++ b/darwin/Classes/UniversalBleHelper.swift @@ -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) } } diff --git a/darwin/Classes/UniversalBlePlugin.swift b/darwin/Classes/UniversalBlePlugin.swift index e2f41d8..9177ea0 100644 --- a/darwin/Classes/UniversalBlePlugin.swift +++ b/darwin/Classes/UniversalBlePlugin.swift @@ -55,7 +55,7 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral } func enableBluetooth(completion: @escaping (Result) -> 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) { 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) -> 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) { 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) -> 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) -> 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) -> 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 {} diff --git a/example/lib/peripheral_details/peripheral_detail_page.dart b/example/lib/peripheral_details/peripheral_detail_page.dart index c2673a1..9961b03 100644 --- a/example/lib/peripheral_details/peripheral_detail_page.dart +++ b/example/lib/peripheral_details/peripheral_detail_page.dart @@ -59,8 +59,14 @@ class _PeripheralDetailPageState extends State { }); } - void _handleConnectionChange(String deviceId, bool isConnected) { - print('_handleConnectionChange $deviceId, $isConnected'); + void _handleConnectionChange( + String deviceId, + bool isConnected, + String? error, + ) { + print( + '_handleConnectionChange $deviceId, $isConnected ${error != null ? 'Error: $error' : ''}', + ); setState(() { if (deviceId == widget.deviceId) { this.isConnected = isConnected; diff --git a/lib/src/models/ble_connection_update.dart b/lib/src/models/ble_connection_update.dart new file mode 100644 index 0000000..26bb98f --- /dev/null +++ b/lib/src/models/ble_connection_update.dart @@ -0,0 +1,9 @@ +class BleConnectionUpdate { + final bool isConnected; + final String? error; + + BleConnectionUpdate({ + required this.isConnected, + this.error, + }); +} diff --git a/lib/src/models/model_exports.dart b/lib/src/models/model_exports.dart index 0c65eb9..60db6fb 100644 --- a/lib/src/models/model_exports.dart +++ b/lib/src/models/model_exports.dart @@ -1,3 +1,4 @@ +export 'package:universal_ble/src/models/ble_connection_update.dart'; export 'package:universal_ble/src/models/manufacturer_data.dart'; export 'package:universal_ble/src/models/platform_config.dart'; export 'package:universal_ble/src/models/queue_type.dart'; diff --git a/lib/src/universal_ble.dart b/lib/src/universal_ble.dart index 67337b0..d94aa84 100644 --- a/lib/src/universal_ble.dart +++ b/lib/src/universal_ble.dart @@ -70,7 +70,7 @@ class UniversalBle { } /// Connection stream of a device - Stream connectionStream(String deviceId) => + static Stream connectionStream(String deviceId) => _platform.connectionStream(deviceId); /// Connect to a device. @@ -87,13 +87,20 @@ class UniversalBle { try { Completer completer = Completer(); - connectionSubscription = - _platform.connectionStream(deviceId).listen((bool event) { - connectionSubscription?.cancel(); - if (!completer.isCompleted) { - completer.complete(event); - } - }); + connectionSubscription = _platform.connectionStream(deviceId).listen( + (BleConnectionUpdate event) { + connectionSubscription?.cancel(); + if (!completer.isCompleted) { + String? error = event.error; + if (error != null) { + connectionSubscription?.cancel(); + completer.completeError(error); + } else { + completer.complete(event.isConnected); + } + } + }, + ); _platform .connect(deviceId, connectionTimeout: connectionTimeout) diff --git a/lib/src/universal_ble_pigeon/universal_ble.g.dart b/lib/src/universal_ble_pigeon/universal_ble.g.dart index c396691..b50e57e 100644 --- a/lib/src/universal_ble_pigeon/universal_ble.g.dart +++ b/lib/src/universal_ble_pigeon/universal_ble.g.dart @@ -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 // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers @@ -15,8 +15,7 @@ PlatformException _createConnectionError(String channelName) { ); } -List wrapResponse( - {Object? result, PlatformException? error, bool empty = false}) { +List wrapResponse({Object? result, PlatformException? error, bool empty = false}) { if (empty) { return []; } @@ -44,9 +43,9 @@ class UniversalBleScanResult { int? rssi; - List? manufacturerDataList; + List? manufacturerDataList; - List? services; + List? services; Object encode() { return [ @@ -66,9 +65,8 @@ class UniversalBleScanResult { name: result[1] as String?, isPaired: result[2] as bool?, rssi: result[3] as int?, - manufacturerDataList: - (result[4] as List?)?.cast(), - services: (result[5] as List?)?.cast(), + manufacturerDataList: (result[4] as List?)?.cast(), + services: (result[5] as List?)?.cast(), ); } } @@ -81,7 +79,7 @@ class UniversalBleService { String uuid; - List? characteristics; + List? characteristics; Object encode() { return [ @@ -94,8 +92,7 @@ class UniversalBleService { result as List; return UniversalBleService( uuid: result[0]! as String, - characteristics: - (result[1] as List?)?.cast(), + characteristics: (result[1] as List?)?.cast(), ); } } @@ -108,7 +105,7 @@ class UniversalBleCharacteristic { String uuid; - List properties; + List properties; Object encode() { return [ @@ -121,7 +118,7 @@ class UniversalBleCharacteristic { result as List; return UniversalBleCharacteristic( uuid: result[0]! as String, - properties: (result[1] as List?)!.cast(), + properties: (result[1] as List?)!.cast(), ); } } @@ -134,11 +131,11 @@ class UniversalScanFilter { required this.withManufacturerData, }); - List withServices; + List withServices; - List withNamePrefix; + List withNamePrefix; - List withManufacturerData; + List withManufacturerData; Object encode() { return [ @@ -151,10 +148,9 @@ class UniversalScanFilter { static UniversalScanFilter decode(Object result) { result as List; return UniversalScanFilter( - withServices: (result[0] as List?)!.cast(), - withNamePrefix: (result[1] as List?)!.cast(), - withManufacturerData: (result[2] as List?)! - .cast(), + withServices: (result[0] as List?)!.cast(), + withNamePrefix: (result[1] as List?)!.cast(), + withManufacturerData: (result[2] as List?)!.cast(), ); } } @@ -216,26 +212,30 @@ class UniversalManufacturerData { } } + class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override void writeValue(WriteBuffer buffer, Object? value) { - if (value is UniversalBleScanResult) { + if (value is int) { + buffer.putUint8(4); + buffer.putInt64(value); + } else if (value is UniversalBleScanResult) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else if (value is UniversalBleService) { + } else if (value is UniversalBleService) { buffer.putUint8(130); writeValue(buffer, value.encode()); - } else if (value is UniversalBleCharacteristic) { + } else if (value is UniversalBleCharacteristic) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else if (value is UniversalScanFilter) { + } else if (value is UniversalScanFilter) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else if (value is UniversalManufacturerDataFilter) { + } else if (value is UniversalManufacturerDataFilter) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else if (value is UniversalManufacturerData) { + } else if (value is UniversalManufacturerData) { buffer.putUint8(134); writeValue(buffer, value.encode()); } else { @@ -246,17 +246,17 @@ class _PigeonCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 129: + case 129: return UniversalBleScanResult.decode(readValue(buffer)!); - case 130: + case 130: return UniversalBleService.decode(readValue(buffer)!); - case 131: + case 131: return UniversalBleCharacteristic.decode(readValue(buffer)!); - case 132: + case 132: return UniversalScanFilter.decode(readValue(buffer)!); - case 133: + case 133: return UniversalManufacturerDataFilter.decode(readValue(buffer)!); - case 134: + case 134: return UniversalManufacturerData.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -269,93 +269,85 @@ class UniversalBlePlatformChannel { /// Constructor for [UniversalBlePlatformChannel]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - UniversalBlePlatformChannel( - {BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) - : __pigeon_binaryMessenger = binaryMessenger, - __pigeon_messageChannelSuffix = - messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; - final BinaryMessenger? __pigeon_binaryMessenger; + UniversalBlePlatformChannel({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) + : pigeonVar_binaryMessenger = binaryMessenger, + pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + final BinaryMessenger? pigeonVar_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); - final String __pigeon_messageChannelSuffix; + final String pigeonVar_messageChannelSuffix; Future getBluetoothAvailabilityState() async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.getBluetoothAvailabilityState$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, + final String pigeonVar_channelName = 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.getBluetoothAvailabilityState$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send(null) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as int?)!; + return (pigeonVar_replyList[0] as int?)!; } } Future enableBluetooth() async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.enableBluetooth$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, + final String pigeonVar_channelName = 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.enableBluetooth$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send(null) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as bool?)!; + return (pigeonVar_replyList[0] as bool?)!; } } Future startScan(UniversalScanFilter? filter) async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.startScan$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, + final String pigeonVar_channelName = 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.startScan$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([filter]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([filter]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -363,23 +355,21 @@ class UniversalBlePlatformChannel { } Future stopScan() async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.stopScan$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, + final String pigeonVar_channelName = 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.stopScan$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send(null) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -387,23 +377,21 @@ class UniversalBlePlatformChannel { } Future connect(String deviceId) async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.connect$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, + final String pigeonVar_channelName = 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.connect$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([deviceId]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([deviceId]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -411,169 +399,146 @@ class UniversalBlePlatformChannel { } Future disconnect(String deviceId) async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.disconnect$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, + final String pigeonVar_channelName = 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.disconnect$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([deviceId]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([deviceId]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; } } - Future setNotifiable(String deviceId, String service, - String characteristic, int bleInputProperty) async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.setNotifiable$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, + Future setNotifiable(String deviceId, String service, String characteristic, int bleInputProperty) async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.setNotifiable$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel.send( - [deviceId, service, characteristic, bleInputProperty]) - as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([deviceId, service, characteristic, bleInputProperty]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; } } - Future> discoverServices(String deviceId) async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.discoverServices$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, + Future> discoverServices(String deviceId) async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.discoverServices$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([deviceId]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([deviceId]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as List?)! - .cast(); + return (pigeonVar_replyList[0] as List?)!.cast(); } } - Future readValue( - String deviceId, String service, String characteristic) async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.readValue$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, + Future readValue(String deviceId, String service, String characteristic) async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.readValue$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel - .send([deviceId, service, characteristic]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([deviceId, service, characteristic]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as Uint8List?)!; + return (pigeonVar_replyList[0] as Uint8List?)!; } } Future requestMtu(String deviceId, int expectedMtu) async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.requestMtu$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, + final String pigeonVar_channelName = 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.requestMtu$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel - .send([deviceId, expectedMtu]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([deviceId, expectedMtu]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as int?)!; + return (pigeonVar_replyList[0] as int?)!; } } - Future writeValue(String deviceId, String service, - String characteristic, Uint8List value, int bleOutputProperty) async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.writeValue$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, + Future writeValue(String deviceId, String service, String characteristic, Uint8List value, int bleOutputProperty) async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.writeValue$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel - .send([ - deviceId, - service, - characteristic, - value, - bleOutputProperty - ]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([deviceId, service, characteristic, value, bleOutputProperty]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -581,144 +546,132 @@ class UniversalBlePlatformChannel { } Future isPaired(String deviceId) async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.isPaired$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, + final String pigeonVar_channelName = 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.isPaired$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([deviceId]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([deviceId]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as bool?)!; + return (pigeonVar_replyList[0] as bool?)!; } } Future pair(String deviceId) async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.pair$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, + final String pigeonVar_channelName = 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.pair$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([deviceId]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([deviceId]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as bool?)!; + return (pigeonVar_replyList[0] as bool?)!; } } Future unPair(String deviceId) async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.unPair$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, + final String pigeonVar_channelName = 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.unPair$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([deviceId]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([deviceId]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; } } - Future> getSystemDevices( - List withServices) async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.getSystemDevices$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, + Future> getSystemDevices(List withServices) async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.getSystemDevices$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([withServices]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([withServices]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as List?)! - .cast(); + return (pigeonVar_replyList[0] as List?)!.cast(); } } Future getConnectionState(String deviceId) async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.getConnectionState$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, + final String pigeonVar_channelName = 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.getConnectionState$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([deviceId]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([deviceId]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as int?)!; + return (pigeonVar_replyList[0] as int?)!; } } } @@ -733,30 +686,22 @@ abstract class UniversalBleCallbackChannel { void onScanResult(UniversalBleScanResult result); - void onValueChanged( - String deviceId, String characteristicId, Uint8List value); + void onValueChanged(String deviceId, String characteristicId, Uint8List value); - void onConnectionChanged(String deviceId, bool connected); + void onConnectionChanged(String deviceId, bool connected, String? error); - static void setUp( - UniversalBleCallbackChannel? api, { - BinaryMessenger? binaryMessenger, - String messageChannelSuffix = '', - }) { - messageChannelSuffix = - messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + static void setUp(UniversalBleCallbackChannel? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) { + messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onAvailabilityChanged$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onAvailabilityChanged$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onAvailabilityChanged was null.'); + 'Argument for dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onAvailabilityChanged was null.'); final List args = (message as List?)!; final int? arg_state = (args[0] as int?); assert(arg_state != null, @@ -766,25 +711,22 @@ abstract class UniversalBleCallbackChannel { return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); } }); } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onPairStateChange$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onPairStateChange$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onPairStateChange was null.'); + 'Argument for dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onPairStateChange was null.'); final List args = (message as List?)!; final String? arg_deviceId = (args[0] as String?); assert(arg_deviceId != null, @@ -798,28 +740,24 @@ abstract class UniversalBleCallbackChannel { return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); } }); } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onScanResult$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onScanResult$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onScanResult was null.'); + 'Argument for dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onScanResult was null.'); final List args = (message as List?)!; - final UniversalBleScanResult? arg_result = - (args[0] as UniversalBleScanResult?); + final UniversalBleScanResult? arg_result = (args[0] as UniversalBleScanResult?); assert(arg_result != null, 'Argument for dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onScanResult was null, expected non-null UniversalBleScanResult.'); try { @@ -827,25 +765,22 @@ abstract class UniversalBleCallbackChannel { return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); } }); } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onValueChanged$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onValueChanged$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onValueChanged was null.'); + 'Argument for dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onValueChanged was null.'); final List args = (message as List?)!; final String? arg_deviceId = (args[0] as String?); assert(arg_deviceId != null, @@ -857,30 +792,26 @@ abstract class UniversalBleCallbackChannel { assert(arg_value != null, 'Argument for dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onValueChanged was null, expected non-null Uint8List.'); try { - api.onValueChanged( - arg_deviceId!, arg_characteristicId!, arg_value!); + api.onValueChanged(arg_deviceId!, arg_characteristicId!, arg_value!); return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); } }); } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onConnectionChanged$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onConnectionChanged$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - __pigeon_channel.setMessageHandler(null); + pigeonVar_channel.setMessageHandler(null); } else { - __pigeon_channel.setMessageHandler((Object? message) async { + pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onConnectionChanged was null.'); + 'Argument for dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onConnectionChanged was null.'); final List args = (message as List?)!; final String? arg_deviceId = (args[0] as String?); assert(arg_deviceId != null, @@ -888,14 +819,14 @@ abstract class UniversalBleCallbackChannel { final bool? arg_connected = (args[1] as bool?); assert(arg_connected != null, 'Argument for dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onConnectionChanged was null, expected non-null bool.'); + final String? arg_error = (args[2] as String?); try { - api.onConnectionChanged(arg_deviceId!, arg_connected!); + api.onConnectionChanged(arg_deviceId!, arg_connected!, arg_error); return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); } }); } diff --git a/lib/src/universal_ble_pigeon/universal_ble_pigeon_channel.dart b/lib/src/universal_ble_pigeon/universal_ble_pigeon_channel.dart index 99d1d89..cdc2b47 100644 --- a/lib/src/universal_ble_pigeon/universal_ble_pigeon_channel.dart +++ b/lib/src/universal_ble_pigeon/universal_ble_pigeon_channel.dart @@ -119,10 +119,7 @@ class UniversalBlePigeonChannel extends UniversalBlePlatform { ) async { var devices = await _channel.getSystemDevices(withServices ?? []); return List.from( - devices - .map((e) => e?.toBleDevice(isSystemDevice: true)) - .where((e) => e != null) - .toList(), + devices.map((e) => e.toBleDevice(isSystemDevice: true)).toList(), ); } @@ -175,8 +172,8 @@ class _UniversalBleCallbackHandler extends UniversalBleCallbackChannel { availabilityChange(AvailabilityState.parse(state)); @override - void onConnectionChanged(String deviceId, bool connected) => - connectionChanged(deviceId, connected); + void onConnectionChanged(String deviceId, bool connected, String? error) => + connectionChanged(deviceId, connected, error); @override void onScanResult(UniversalBleScanResult result) => @@ -200,9 +197,9 @@ extension _UniversalBleScanResultExtension on UniversalBleScanResult { rssi: rssi, isPaired: isPaired, isSystemDevice: isSystemDevice, - services: services?.nonNulls.map(BleUuidParser.string).toList() ?? [], - manufacturerDataList: manufacturerDataList?.nonNulls - .map((e) => ManufacturerData(e.companyIdentifier, e.data)) + services: services?.map(BleUuidParser.string).toList() ?? [], + manufacturerDataList: manufacturerDataList + ?.map((e) => ManufacturerData(e.companyIdentifier, e.data)) .toList() ?? [], ); diff --git a/lib/src/universal_ble_platform_interface.dart b/lib/src/universal_ble_platform_interface.dart index b539cd8..7f45144 100644 --- a/lib/src/universal_ble_platform_interface.dart +++ b/lib/src/universal_ble_platform_interface.dart @@ -4,7 +4,9 @@ import 'dart:typed_data'; import 'package:universal_ble/universal_ble.dart'; abstract class UniversalBlePlatform { - StreamController? _connectionStreamController; + StreamController<({String deviceId, bool isConnected, String? error})>? + _connectionStreamController; + final Map _pairStateMap = {}; Future getBluetoothAvailabilityState(); @@ -57,21 +59,27 @@ abstract class UniversalBlePlatform { bool receivesAdvertisements(String deviceId) => true; - Stream connectionStream(String deviceId) { + Stream connectionStream(String deviceId) { _setupConnectionStreamIfRequired(); return _connectionStreamController!.stream .where((event) => event.deviceId == deviceId) - .map((event) => event.isConnected); + .map((event) => BleConnectionUpdate( + isConnected: event.isConnected, + error: event.error, + )); } void updateScanResult(BleDevice bleDevice) { onScanResult?.call(bleDevice); } - void updateConnection(String deviceId, bool isConnected) { - onConnectionChange?.call(deviceId, isConnected); - _connectionStreamController - ?.add((deviceId: deviceId, isConnected: isConnected)); + void updateConnection(String deviceId, bool isConnected, [String? error]) { + onConnectionChange?.call(deviceId, isConnected, error); + _connectionStreamController?.add(( + deviceId: deviceId, + isConnected: isConnected, + error: error, + )); } void updateCharacteristicValue( @@ -106,8 +114,7 @@ abstract class UniversalBlePlatform { void _setupConnectionStreamIfRequired() { if (_connectionStreamController != null) return; - _connectionStreamController = - StreamController<({String deviceId, bool isConnected})>.broadcast(); + _connectionStreamController = StreamController.broadcast(); // Auto dispose if no more subscribers _connectionStreamController?.onCancel = () { @@ -119,7 +126,8 @@ abstract class UniversalBlePlatform { } // Callback types -typedef OnConnectionChange = void Function(String deviceId, bool isConnected); +typedef OnConnectionChange = void Function( + String deviceId, bool isConnected, String? error); typedef OnValueChange = void Function( String deviceId, String characteristicId, Uint8List value); diff --git a/pigeon/universal_ble.dart b/pigeon/universal_ble.dart index ff57f65..224865d 100644 --- a/pigeon/universal_ble.dart +++ b/pigeon/universal_ble.dart @@ -99,6 +99,7 @@ abstract class UniversalBleCallbackChannel { void onConnectionChanged( String deviceId, bool connected, + String? error, ); } @@ -107,8 +108,8 @@ class UniversalBleScanResult { final String? name; final bool? isPaired; final int? rssi; - final List? manufacturerDataList; - final List? services; + final List? manufacturerDataList; + final List? services; UniversalBleScanResult({ required this.name, @@ -122,21 +123,21 @@ class UniversalBleScanResult { class UniversalBleService { String uuid; - List? characteristics; + List? characteristics; UniversalBleService(this.uuid, this.characteristics); } class UniversalBleCharacteristic { String uuid; - List properties; + List properties; UniversalBleCharacteristic(this.uuid, this.properties); } /// Scan Filters class UniversalScanFilter { - final List withServices; - final List withNamePrefix; - final List withManufacturerData; + final List withServices; + final List withNamePrefix; + final List withManufacturerData; UniversalScanFilter( this.withServices, diff --git a/pubspec.yaml b/pubspec.yaml index 0a60599..4fd5116 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -30,7 +30,7 @@ dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^2.0.0 - pigeon: ^21.1.0 + pigeon: ^22.4.0 flutter: plugin: diff --git a/windows/src/generated/universal_ble.g.cpp b/windows/src/generated/universal_ble.g.cpp index 72f40e2..810b7af 100644 --- a/windows/src/generated/universal_ble.g.cpp +++ b/windows/src/generated/universal_ble.g.cpp @@ -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 #undef _HAS_EXCEPTIONS @@ -22,10 +22,10 @@ using flutter::EncodableMap; using flutter::EncodableValue; FlutterError CreateConnectionError(const std::string channel_name) { - return FlutterError( - "channel-error", - "Unable to establish connection on channel: '" + channel_name + "'.", - EncodableValue("")); + return FlutterError( + "channel-error", + "Unable to establish connection on channel: '" + channel_name + "'.", + EncodableValue("")); } // UniversalBleScanResult @@ -146,7 +146,7 @@ UniversalBleScanResult UniversalBleScanResult::FromEncodableList(const Encodable } auto& encodable_rssi = list[3]; if (!encodable_rssi.IsNull()) { - decoded.set_rssi(encodable_rssi.LongValue()); + decoded.set_rssi(std::get(encodable_rssi)); } auto& encodable_manufacturer_data_list = list[4]; if (!encodable_manufacturer_data_list.IsNull()) { @@ -364,7 +364,7 @@ EncodableList UniversalManufacturerDataFilter::ToEncodableList() const { UniversalManufacturerDataFilter UniversalManufacturerDataFilter::FromEncodableList(const EncodableList& list) { UniversalManufacturerDataFilter decoded( - list[0].LongValue()); + std::get(list[0])); auto& encodable_data = list[1]; if (!encodable_data.IsNull()) { decoded.set_data(std::get>(encodable_data)); @@ -412,36 +412,42 @@ EncodableList UniversalManufacturerData::ToEncodableList() const { UniversalManufacturerData UniversalManufacturerData::FromEncodableList(const EncodableList& list) { UniversalManufacturerData decoded( - list[0].LongValue(), + std::get(list[0]), std::get>(list[1])); return decoded; } -PigeonCodecSerializer::PigeonCodecSerializer() {} +PigeonInternalCodecSerializer::PigeonInternalCodecSerializer() {} -EncodableValue PigeonCodecSerializer::ReadValueOfType( +EncodableValue PigeonInternalCodecSerializer::ReadValueOfType( uint8_t type, flutter::ByteStreamReader* stream) const { switch (type) { - case 129: - return CustomEncodableValue(UniversalBleScanResult::FromEncodableList(std::get(ReadValue(stream)))); - case 130: - return CustomEncodableValue(UniversalBleService::FromEncodableList(std::get(ReadValue(stream)))); - case 131: - return CustomEncodableValue(UniversalBleCharacteristic::FromEncodableList(std::get(ReadValue(stream)))); - case 132: - return CustomEncodableValue(UniversalScanFilter::FromEncodableList(std::get(ReadValue(stream)))); - case 133: - return CustomEncodableValue(UniversalManufacturerDataFilter::FromEncodableList(std::get(ReadValue(stream)))); - case 134: - return CustomEncodableValue(UniversalManufacturerData::FromEncodableList(std::get(ReadValue(stream)))); + case 129: { + return CustomEncodableValue(UniversalBleScanResult::FromEncodableList(std::get(ReadValue(stream)))); + } + case 130: { + return CustomEncodableValue(UniversalBleService::FromEncodableList(std::get(ReadValue(stream)))); + } + case 131: { + return CustomEncodableValue(UniversalBleCharacteristic::FromEncodableList(std::get(ReadValue(stream)))); + } + case 132: { + return CustomEncodableValue(UniversalScanFilter::FromEncodableList(std::get(ReadValue(stream)))); + } + case 133: { + return CustomEncodableValue(UniversalManufacturerDataFilter::FromEncodableList(std::get(ReadValue(stream)))); + } + case 134: { + return CustomEncodableValue(UniversalManufacturerData::FromEncodableList(std::get(ReadValue(stream)))); + } default: return flutter::StandardCodecSerializer::ReadValueOfType(type, stream); } } -void PigeonCodecSerializer::WriteValue( +void PigeonInternalCodecSerializer::WriteValue( const EncodableValue& value, flutter::ByteStreamWriter* stream) const { if (const CustomEncodableValue* custom_value = std::get_if(&value)) { @@ -481,7 +487,7 @@ void PigeonCodecSerializer::WriteValue( /// The codec used by UniversalBlePlatformChannel. const flutter::StandardMessageCodec& UniversalBlePlatformChannel::GetCodec() { - return flutter::StandardMessageCodec::GetInstance(&PigeonCodecSerializer::GetInstance()); + return flutter::StandardMessageCodec::GetInstance(&PigeonInternalCodecSerializer::GetInstance()); } // Sets up an instance of `UniversalBlePlatformChannel` to handle messages through the `binary_messenger`. @@ -1019,7 +1025,7 @@ UniversalBleCallbackChannel::UniversalBleCallbackChannel( message_channel_suffix_(message_channel_suffix.length() > 0 ? std::string(".") + message_channel_suffix : "") {} const flutter::StandardMessageCodec& UniversalBleCallbackChannel::GetCodec() { - return flutter::StandardMessageCodec::GetInstance(&PigeonCodecSerializer::GetInstance()); + return flutter::StandardMessageCodec::GetInstance(&PigeonInternalCodecSerializer::GetInstance()); } void UniversalBleCallbackChannel::OnAvailabilityChanged( @@ -1133,6 +1139,7 @@ void UniversalBleCallbackChannel::OnValueChanged( void UniversalBleCallbackChannel::OnConnectionChanged( const std::string& device_id_arg, bool connected_arg, + const std::string* error_arg, std::function&& on_success, std::function&& on_error) { const std::string channel_name = "dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onConnectionChanged" + message_channel_suffix_; @@ -1140,6 +1147,7 @@ void UniversalBleCallbackChannel::OnConnectionChanged( EncodableValue encoded_api_arguments = EncodableValue(EncodableList{ EncodableValue(device_id_arg), EncodableValue(connected_arg), + error_arg ? EncodableValue(*error_arg) : EncodableValue(), }); channel.Send(encoded_api_arguments, [channel_name, on_success = std::move(on_success), on_error = std::move(on_error)](const uint8_t* reply, size_t reply_size) { std::unique_ptr response = GetCodec().DecodeMessage(reply, reply_size); diff --git a/windows/src/generated/universal_ble.g.h b/windows/src/generated/universal_ble.g.h index edfca14..1fe32e0 100644 --- a/windows/src/generated/universal_ble.g.h +++ b/windows/src/generated/universal_ble.g.h @@ -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 #ifndef PIGEON_UNIVERSAL_BLE_G_H_ @@ -57,6 +57,7 @@ template class ErrorOr { }; + // Generated class from Pigeon that represents data sent in messages. class UniversalBleScanResult { public: @@ -101,7 +102,7 @@ class UniversalBleScanResult { flutter::EncodableList ToEncodableList() const; friend class UniversalBlePlatformChannel; friend class UniversalBleCallbackChannel; - friend class PigeonCodecSerializer; + friend class PigeonInternalCodecSerializer; std::string device_id_; std::optional name_; std::optional is_paired_; @@ -136,7 +137,7 @@ class UniversalBleService { flutter::EncodableList ToEncodableList() const; friend class UniversalBlePlatformChannel; friend class UniversalBleCallbackChannel; - friend class PigeonCodecSerializer; + friend class PigeonInternalCodecSerializer; std::string uuid_; std::optional characteristics_; @@ -163,7 +164,7 @@ class UniversalBleCharacteristic { flutter::EncodableList ToEncodableList() const; friend class UniversalBlePlatformChannel; friend class UniversalBleCallbackChannel; - friend class PigeonCodecSerializer; + friend class PigeonInternalCodecSerializer; std::string uuid_; flutter::EncodableList properties_; @@ -196,7 +197,7 @@ class UniversalScanFilter { flutter::EncodableList ToEncodableList() const; friend class UniversalBlePlatformChannel; friend class UniversalBleCallbackChannel; - friend class PigeonCodecSerializer; + friend class PigeonInternalCodecSerializer; flutter::EncodableList with_services_; flutter::EncodableList with_name_prefix_; flutter::EncodableList with_manufacturer_data_; @@ -233,7 +234,7 @@ class UniversalManufacturerDataFilter { flutter::EncodableList ToEncodableList() const; friend class UniversalBlePlatformChannel; friend class UniversalBleCallbackChannel; - friend class PigeonCodecSerializer; + friend class PigeonInternalCodecSerializer; int64_t company_identifier_; std::optional> data_; std::optional> mask_; @@ -261,17 +262,18 @@ class UniversalManufacturerData { flutter::EncodableList ToEncodableList() const; friend class UniversalBlePlatformChannel; friend class UniversalBleCallbackChannel; - friend class PigeonCodecSerializer; + friend class PigeonInternalCodecSerializer; int64_t company_identifier_; std::vector data_; }; -class PigeonCodecSerializer : public flutter::StandardCodecSerializer { + +class PigeonInternalCodecSerializer : public flutter::StandardCodecSerializer { public: - PigeonCodecSerializer(); - inline static PigeonCodecSerializer& GetInstance() { - static PigeonCodecSerializer sInstance; + PigeonInternalCodecSerializer(); + inline static PigeonInternalCodecSerializer& GetInstance() { + static PigeonInternalCodecSerializer sInstance; return sInstance; } @@ -387,6 +389,7 @@ class UniversalBleCallbackChannel { void OnConnectionChanged( const std::string& device_id, bool connected, + const std::string* error, std::function&& on_success, std::function&& on_error);