From f4b197f8ae9690f3c2b31aa7c01bb6b3282e3b74 Mon Sep 17 00:00:00 2001 From: Raphael Smith Date: Wed, 1 Apr 2026 21:15:39 +0200 Subject: [PATCH] Add requestConnectionPriority support (#221) * feat: add requestConnectionPriority - Add BleConnectionPriority enum (balanced, highPerformance, lowPower) - Add BleCapabilities.supportsConnectionPriorityApi flag - Implement on Android via BluetoothGatt.requestConnectionPriority() - Throw notSupported on iOS, macOS, Windows, Linux, and Web - Update pigeon definition and regenerate platform channel files - Bump version 1.2.0 -> 1.3.0 * fix: improve requestConnectionPriority implementation - Remove redundant BleCapabilities guard in Dart layer (native handles it) - Add BleConnectionPriority Kotlin enum mirroring Dart enum - Map to explicit Android SDK constants via when expression - Add firstOrNull with ILLEGAL_ARGUMENT for unknown priority values - Add catch (e: Exception) block for broader error handling - Fix enum doc comment (throws belongs on method, not enum) - Remove stale capability check guidance from docs and README --------- Co-authored-by: aqeel-bmec-co Co-authored-by: aqeel-bmec-co <85945830+aqeel-bmec-co@users.noreply.github.com> --- CHANGELOG.md | 3 ++ README.md | 16 ++++++ .../navideck/universal_ble/UniversalBle.g.kt | 21 ++++++++ .../universal_ble/UniversalBleHelper.kt | 5 ++ .../universal_ble/UniversalBlePlugin.kt | 49 +++++++++++++++++++ darwin/Classes/UniversalBle.g.swift | 19 +++++++ darwin/Classes/UniversalBlePlugin.swift | 8 +++ example/lib/data/mock_universal_ble.dart | 6 +++ lib/src/models/ble_capabilities.dart | 3 ++ lib/src/models/ble_connection_priority.dart | 13 +++++ lib/src/models/model_exports.dart | 1 + lib/src/universal_ble.dart | 24 +++++++++ .../universal_ble_linux.dart | 11 +++++ .../universal_ble_pigeon/universal_ble.g.dart | 24 +++++++++ .../universal_ble_pigeon_channel.dart | 8 +++ lib/src/universal_ble_platform_interface.dart | 5 ++ .../universal_ble_web/universal_ble_web.dart | 12 +++++ pigeon/universal_ble.dart | 3 ++ pubspec.yaml | 2 +- test/universal_ble_test_mock.dart | 8 +++ windows/src/generated/universal_ble.g.cpp | 35 +++++++++++++ windows/src/generated/universal_ble.g.h | 4 ++ windows/src/universal_ble_plugin.cpp | 8 +++ windows/src/universal_ble_plugin.h | 3 ++ 24 files changed, 290 insertions(+), 1 deletion(-) create mode 100644 lib/src/models/ble_connection_priority.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index fc747a9..3f2a203 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.3.0 +* Add `requestConnectionPriority` to allow tuning BLE connection intervals on Android + ## 1.2.0 * Add `autoConnect` parameter to `connect()` method for automatic reconnection support on Android and iOS/macOS * Add `serviceData` in `BleDevice` diff --git a/README.md b/README.md index 54d700e..73ea212 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ A cross-platform (Android/iOS/macOS/Windows/Linux/Web) Bluetooth Low Energy (BLE | enable/disable Bluetooth | ✔️ | ❌ | ❌ | ✔️ | ✔️ | ❌ | | onAvailabilityChange | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | requestMtu | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ❌ | +| requestConnectionPriority | ✔️ | ❌ | ❌ | ❌ | ❌ | ❌ | | readRssi | ✔️ | ✔️ | ✔️ | ❌ | 🚧 | ❌ | | requestPermissions | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | @@ -470,6 +471,21 @@ When developing cross-platform BLE applications and devices: * Take advantage of higher MTUs when available, without depending on them +### Requesting Connection Priority + +On Android, you can request a connection parameter update to tune the BLE connection interval. This can yield a 3–7× throughput improvement for data-intensive transfers. + +```dart +// Before starting high-throughput data transfer: +await UniversalBle.requestConnectionPriority( + deviceId, + BleConnectionPriority.highPerformance, +); +``` + +> **Note:** Only supported on Android. On all other platforms this throws `UniversalBleException` with code `notSupported`. +> Call this after connecting and after `requestMtu()`, before beginning data transfer. + ### Reading RSSI Read the signal strength (RSSI) of a connected device. 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 5bd811a..2118809 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 @@ -645,6 +645,7 @@ interface UniversalBlePlatformChannel { fun getSystemDevices(withServices: List, callback: (Result>) -> Unit) fun getConnectionState(deviceId: String): Long fun readRssi(deviceId: String, callback: (Result) -> Unit) + fun requestConnectionPriority(deviceId: String, priority: Long, callback: (Result) -> Unit) fun setLogLevel(logLevel: UniversalBleLogLevel) companion object { @@ -1057,6 +1058,26 @@ interface UniversalBlePlatformChannel { channel.setMessageHandler(null) } } + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.requestConnectionPriority$separatedMessageChannelSuffix", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val deviceIdArg = args[0] as String + val priorityArg = args[1] as Long + api.requestConnectionPriority(deviceIdArg, priorityArg) { result: Result -> + val error = result.exceptionOrNull() + if (error != null) { + reply.reply(UniversalBlePigeonUtils.wrapError(error)) + } else { + reply.reply(UniversalBlePigeonUtils.wrapResult(null)) + } + } + } + } else { + channel.setMessageHandler(null) + } + } run { val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.setLogLevel$separatedMessageChannelSuffix", codec) if (api != null) { 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 6a643d1..248cf48 100644 --- a/android/src/main/kotlin/com/navideck/universal_ble/UniversalBleHelper.kt +++ b/android/src/main/kotlin/com/navideck/universal_ble/UniversalBleHelper.kt @@ -53,6 +53,11 @@ enum class BleOutputProperty(val value: Long) { WithoutResponse(1); } +enum class BleConnectionPriority(val value: Long) { + Balanced(0), + HighPerformance(1), + LowPower(2); +} enum class CharacteristicProperty(val value: Long) { Broadcast(0), 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 8e85942..beac594 100644 --- a/android/src/main/kotlin/com/navideck/universal_ble/UniversalBlePlugin.kt +++ b/android/src/main/kotlin/com/navideck/universal_ble/UniversalBlePlugin.kt @@ -752,6 +752,55 @@ class UniversalBlePlugin : UniversalBlePlatformChannel, BluetoothGattCallback(), } } + override fun requestConnectionPriority( + deviceId: String, + priority: Long, + callback: (Result) -> Unit, + ) { + try { + val gatt = deviceId.toBluetoothGatt() + val priorityEnum = BleConnectionPriority.entries.firstOrNull { it.value == priority } + ?: return callback( + Result.failure( + createFlutterError( + UniversalBleErrorCode.ILLEGAL_ARGUMENT, + "Unknown priority: $priority" + ) + ) + ) + val androidPriority = when (priorityEnum) { + BleConnectionPriority.Balanced -> BluetoothGatt.CONNECTION_PRIORITY_BALANCED + BleConnectionPriority.HighPerformance -> BluetoothGatt.CONNECTION_PRIORITY_HIGH + BleConnectionPriority.LowPower -> BluetoothGatt.CONNECTION_PRIORITY_LOW_POWER + } + val success = gatt.requestConnectionPriority(androidPriority) + if (success) { + callback(Result.success(Unit)) + } else { + callback( + Result.failure( + createFlutterError( + UniversalBleErrorCode.FAILED, + "requestConnectionPriority returned false", + ), + ), + ) + } + } catch (e: FlutterError) { + callback(Result.failure(e)) + } catch (e: Exception) { + callback( + Result.failure( + createFlutterError( + UniversalBleErrorCode.FAILED, + "requestConnectionPriority failed", + e.toString() + ) + ) + ) + } + } + override fun onMtuChanged(gatt: BluetoothGatt?, mtu: Int, status: Int) { val deviceId = gatt?.device?.address ?: return mtuResultFutureList.removeAll { diff --git a/darwin/Classes/UniversalBle.g.swift b/darwin/Classes/UniversalBle.g.swift index b9589a9..dc40b39 100644 --- a/darwin/Classes/UniversalBle.g.swift +++ b/darwin/Classes/UniversalBle.g.swift @@ -645,6 +645,7 @@ protocol UniversalBlePlatformChannel { func getSystemDevices(withServices: [String], completion: @escaping (Result<[UniversalBleScanResult], Error>) -> Void) func getConnectionState(deviceId: String) throws -> Int64 func readRssi(deviceId: String, completion: @escaping (Result) -> Void) + func requestConnectionPriority(deviceId: String, priority: Int64, completion: @escaping (Result) -> Void) func setLogLevel(logLevel: UniversalBleLogLevel) throws } @@ -998,6 +999,24 @@ class UniversalBlePlatformChannelSetup { } else { readRssiChannel.setMessageHandler(nil) } + let requestConnectionPriorityChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.requestConnectionPriority\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + requestConnectionPriorityChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let deviceIdArg = args[0] as! String + let priorityArg = args[1] as! Int64 + api.requestConnectionPriority(deviceId: deviceIdArg, priority: priorityArg) { result in + switch result { + case .success: + reply(wrapResult(nil)) + case .failure(let error): + reply(wrapError(error)) + } + } + } + } else { + requestConnectionPriorityChannel.setMessageHandler(nil) + } let setLogLevelChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.setLogLevel\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { setLogLevelChannel.setMessageHandler { message, reply in diff --git a/darwin/Classes/UniversalBlePlugin.swift b/darwin/Classes/UniversalBlePlugin.swift index 90b25b1..4f6b1fb 100644 --- a/darwin/Classes/UniversalBlePlugin.swift +++ b/darwin/Classes/UniversalBlePlugin.swift @@ -371,6 +371,14 @@ private class BleCentralDarwin: NSObject, UniversalBlePlatformChannel, CBCentral completion(Result.success(mtuResult)) } + func requestConnectionPriority( + deviceId _: String, + priority _: Int64, + completion: @escaping (Result) -> Void + ) { + completion(.failure(createFlutterError(code: .notSupported, message: "requestConnectionPriority is not supported on Apple platforms"))) + } + func readRssi(deviceId: String, completion: @escaping (Result) -> Void) { UniversalBleLogger.shared.logDebug("READ_RSSI -> \(deviceId)") guard let peripheral = deviceId.findPeripheral(manager: manager) else { diff --git a/example/lib/data/mock_universal_ble.dart b/example/lib/data/mock_universal_ble.dart index 6337dad..44a681a 100644 --- a/example/lib/data/mock_universal_ble.dart +++ b/example/lib/data/mock_universal_ble.dart @@ -103,6 +103,12 @@ class MockUniversalBle extends UniversalBlePlatform { return 512; } + @override + Future requestConnectionPriority( + String deviceId, + BleConnectionPriority priority, + ) async {} + @override Future setNotifiable(String deviceId, String service, String characteristic, BleInputProperty bleInputProperty) async {} diff --git a/lib/src/models/ble_capabilities.dart b/lib/src/models/ble_capabilities.dart index 41ab3bc..baa93e3 100644 --- a/lib/src/models/ble_capabilities.dart +++ b/lib/src/models/ble_capabilities.dart @@ -40,6 +40,9 @@ class BleCapabilities { static bool supportsConnectedDevicesApi = !_Platform.isWeb; static bool supportsRequestMtuApi = !_Platform.isWeb; + + static bool supportsConnectionPriorityApi = + !_Platform.isWeb && defaultTargetPlatform == TargetPlatform.android; } class _Platform { diff --git a/lib/src/models/ble_connection_priority.dart b/lib/src/models/ble_connection_priority.dart new file mode 100644 index 0000000..1f858f7 --- /dev/null +++ b/lib/src/models/ble_connection_priority.dart @@ -0,0 +1,13 @@ +/// Connection priority hint passed to [UniversalBle.requestConnectionPriority]. +/// +/// Maps to Android `BluetoothGatt.CONNECTION_PRIORITY_*` constants. +enum BleConnectionPriority { + /// Default OS-managed interval (~30-50 ms). Android constant: 0. + balanced, + + /// Low-latency interval (~7.5-15 ms), higher power draw. Android constant: 1. + highPerformance, + + /// Power-optimised interval (~100-125 ms). Android constant: 2. + lowPower, +} diff --git a/lib/src/models/model_exports.dart b/lib/src/models/model_exports.dart index ac71575..7533772 100644 --- a/lib/src/models/model_exports.dart +++ b/lib/src/models/model_exports.dart @@ -12,3 +12,4 @@ export 'package:universal_ble/src/models/ble_connection_state.dart'; export 'package:universal_ble/src/models/ble_device.dart'; export 'package:universal_ble/src/models/ble_command.dart'; export 'package:universal_ble/src/models/ble_capabilities.dart'; +export 'package:universal_ble/src/models/ble_connection_priority.dart'; diff --git a/lib/src/universal_ble.dart b/lib/src/universal_ble.dart index 65f47e4..70627e6 100644 --- a/lib/src/universal_ble.dart +++ b/lib/src/universal_ble.dart @@ -351,6 +351,30 @@ class UniversalBle { ); } + /// Requests a connection parameter update for [deviceId]. + /// + /// [priority] controls the BLE connection interval: + /// - [BleConnectionPriority.balanced] - default OS behaviour (~30-50 ms interval). + /// - [BleConnectionPriority.highPerformance] - low latency, higher power (~7.5-15 ms interval). + /// - [BleConnectionPriority.lowPower] - power-optimised (~100-125 ms interval). + /// + /// Only supported on Android. On all other platforms this throws + /// [UniversalBleException] with code [UniversalBleErrorCode.notSupported]. + /// + /// Should be called after a successful connection and MTU negotiation, before + /// beginning high-throughput data transfer. + static Future requestConnectionPriority( + String deviceId, + BleConnectionPriority priority, { + Duration? timeout, + }) async { + return await _bleCommandQueue.queueCommand( + () => _platform.requestConnectionPriority(deviceId, priority), + timeout: timeout, + deviceId: deviceId, + ); + } + /// Read the RSSI value of a connected device. /// /// Returns the current RSSI value in dBm. This value indicates the signal strength diff --git a/lib/src/universal_ble_linux/universal_ble_linux.dart b/lib/src/universal_ble_linux/universal_ble_linux.dart index 0086000..aa94693 100644 --- a/lib/src/universal_ble_linux/universal_ble_linux.dart +++ b/lib/src/universal_ble_linux/universal_ble_linux.dart @@ -397,6 +397,17 @@ class UniversalBleLinux extends UniversalBlePlatform { ); } + @override + Future requestConnectionPriority( + String deviceId, + BleConnectionPriority priority, + ) { + throw UniversalBleException( + code: UniversalBleErrorCode.notSupported, + message: "requestConnectionPriority is not supported on Linux platform", + ); + } + @override Future readRssi(String deviceId) async { throw UniversalBleException( diff --git a/lib/src/universal_ble_pigeon/universal_ble.g.dart b/lib/src/universal_ble_pigeon/universal_ble.g.dart index 9fae079..9e023e0 100644 --- a/lib/src/universal_ble_pigeon/universal_ble.g.dart +++ b/lib/src/universal_ble_pigeon/universal_ble.g.dart @@ -1256,6 +1256,30 @@ class UniversalBlePlatformChannel { } } + Future requestConnectionPriority(String deviceId, int priority) async { + final pigeonVar_channelName = + 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.requestConnectionPriority$pigeonVar_messageChannelSuffix'; + final pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger); + final Future pigeonVar_sendFuture = + pigeonVar_channel.send([deviceId, priority]); + final pigeonVar_replyList = + await pigeonVar_sendFuture as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } + Future setLogLevel(UniversalBleLogLevel logLevel) async { final pigeonVar_channelName = 'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.setLogLevel$pigeonVar_messageChannelSuffix'; 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 988a4a2..eb46419 100644 --- a/lib/src/universal_ble_pigeon/universal_ble_pigeon_channel.dart +++ b/lib/src/universal_ble_pigeon/universal_ble_pigeon_channel.dart @@ -158,6 +158,14 @@ class UniversalBlePigeonChannel extends UniversalBlePlatform { Future readRssi(String deviceId) => _executeWithErrorHandling(() => _channel.readRssi(deviceId)); + @override + Future requestConnectionPriority( + String deviceId, + BleConnectionPriority priority, + ) => _executeWithErrorHandling( + () => _channel.requestConnectionPriority(deviceId, priority.index), + ); + @override Future isPaired(String deviceId) => _executeWithErrorHandling(() => _channel.isPaired(deviceId)); diff --git a/lib/src/universal_ble_platform_interface.dart b/lib/src/universal_ble_platform_interface.dart index e85a867..d2c75b9 100644 --- a/lib/src/universal_ble_platform_interface.dart +++ b/lib/src/universal_ble_platform_interface.dart @@ -97,6 +97,11 @@ abstract class UniversalBlePlatform { Future readRssi(String deviceId); + Future requestConnectionPriority( + String deviceId, + BleConnectionPriority priority, + ); + Future isPaired(String deviceId); Future pair(String deviceId); diff --git a/lib/src/universal_ble_web/universal_ble_web.dart b/lib/src/universal_ble_web/universal_ble_web.dart index 910f8b8..b30159f 100644 --- a/lib/src/universal_ble_web/universal_ble_web.dart +++ b/lib/src/universal_ble_web/universal_ble_web.dart @@ -292,6 +292,18 @@ class UniversalBleWeb extends UniversalBlePlatform { ); } + /// `Unimplemented` + @override + Future requestConnectionPriority( + String deviceId, + BleConnectionPriority priority, + ) { + throw UniversalBleException( + code: UniversalBleErrorCode.notSupported, + message: "requestConnectionPriority is not supported on Web platform", + ); + } + /// `Unimplemented` @override Future readRssi(String deviceId) { diff --git a/pigeon/universal_ble.dart b/pigeon/universal_ble.dart index b06e84e..7a767f3 100644 --- a/pigeon/universal_ble.dart +++ b/pigeon/universal_ble.dart @@ -96,6 +96,9 @@ abstract class UniversalBlePlatformChannel { @async int readRssi(String deviceId); + @async + void requestConnectionPriority(String deviceId, int priority); + void setLogLevel(UniversalBleLogLevel logLevel); } diff --git a/pubspec.yaml b/pubspec.yaml index f00e1a2..3a248a1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: universal_ble description: A cross-platform (Android/iOS/macOS/Windows/Linux/Web) Bluetooth Low Energy (BLE) plugin for Flutter -version: 1.2.0 +version: 1.3.0 homepage: https://navideck.com repository: https://github.com/Navideck/universal_ble issue_tracker: https://github.com/Navideck/universal_ble/issues diff --git a/test/universal_ble_test_mock.dart b/test/universal_ble_test_mock.dart index 69bbb9c..e8dd54a 100644 --- a/test/universal_ble_test_mock.dart +++ b/test/universal_ble_test_mock.dart @@ -66,6 +66,14 @@ abstract class UniversalBlePlatformMock extends UniversalBlePlatform { throw UnimplementedError(); } + @override + Future requestConnectionPriority( + String deviceId, + BleConnectionPriority priority, + ) { + throw UnimplementedError(); + } + @override Future setNotifiable(String deviceId, String service, String characteristic, BleInputProperty bleInputProperty) { diff --git a/windows/src/generated/universal_ble.g.cpp b/windows/src/generated/universal_ble.g.cpp index 819a67b..90171ad 100644 --- a/windows/src/generated/universal_ble.g.cpp +++ b/windows/src/generated/universal_ble.g.cpp @@ -1389,6 +1389,41 @@ void UniversalBlePlatformChannel::SetUp( channel.SetMessageHandler(nullptr); } } + { + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.requestConnectionPriority" + prepended_suffix, &GetCodec()); + if (api != nullptr) { + channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_device_id_arg = args.at(0); + if (encodable_device_id_arg.IsNull()) { + reply(WrapError("device_id_arg unexpectedly null.")); + return; + } + const auto& device_id_arg = std::get(encodable_device_id_arg); + const auto& encodable_priority_arg = args.at(1); + if (encodable_priority_arg.IsNull()) { + reply(WrapError("priority_arg unexpectedly null.")); + return; + } + const int64_t priority_arg = encodable_priority_arg.LongValue(); + api->RequestConnectionPriority(device_id_arg, priority_arg, [reply](std::optional&& output) { + if (output.has_value()) { + reply(WrapError(output.value())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); + } else { + channel.SetMessageHandler(nullptr); + } + } { BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.setLogLevel" + prepended_suffix, &GetCodec()); if (api != nullptr) { diff --git a/windows/src/generated/universal_ble.g.h b/windows/src/generated/universal_ble.g.h index 2c1f82e..88cb517 100644 --- a/windows/src/generated/universal_ble.g.h +++ b/windows/src/generated/universal_ble.g.h @@ -528,6 +528,10 @@ class UniversalBlePlatformChannel { virtual void ReadRssi( const std::string& device_id, std::function reply)> result) = 0; + virtual void RequestConnectionPriority( + const std::string& device_id, + int64_t priority, + std::function reply)> result) = 0; virtual std::optional SetLogLevel(const UniversalBleLogLevel& log_level) = 0; // The codec used by UniversalBlePlatformChannel. diff --git a/windows/src/universal_ble_plugin.cpp b/windows/src/universal_ble_plugin.cpp index 1d2c78f..3bf1c2e 100644 --- a/windows/src/universal_ble_plugin.cpp +++ b/windows/src/universal_ble_plugin.cpp @@ -436,6 +436,14 @@ void UniversalBlePlugin::RequestMtu( } } +void UniversalBlePlugin::RequestConnectionPriority( + const std::string &device_id, int64_t priority, + std::function reply)> result) { + result(create_flutter_error( + UniversalBleErrorCode::kNotSupported, + "requestConnectionPriority is not supported on Windows platform")); +} + void UniversalBlePlugin::ReadRssi( const std::string &device_id, std::function reply)> result) { diff --git a/windows/src/universal_ble_plugin.h b/windows/src/universal_ble_plugin.h index 0356e70..867ed41 100644 --- a/windows/src/universal_ble_plugin.h +++ b/windows/src/universal_ble_plugin.h @@ -207,6 +207,9 @@ private: std::function reply)> result) override; void RequestMtu(const std::string &device_id, int64_t expected_mtu, std::function reply)> result) override; + void RequestConnectionPriority( + const std::string &device_id, int64_t priority, + std::function reply)> result) override; void ReadRssi(const std::string &device_id, std::function reply)> result) override; void IsPaired(const std::string &device_id,