Skip to content

Add requestConnectionPriority support#221

Merged
fotiDim merged 4 commits intoNavideck:mainfrom
BMEC:main
Apr 1, 2026
Merged

Add requestConnectionPriority support#221
fotiDim merged 4 commits intoNavideck:mainfrom
BMEC:main

Conversation

@raphael-bmec-co
Copy link
Copy Markdown
Contributor

aqeel-bmec-co and others added 2 commits March 20, 2026 11:01
- 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
…upport

Add requestConnectionPriority support
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Universal BLE plugin by adding support for requesting connection priority, a feature primarily beneficial for Android devices. This allows developers to optimize BLE connection intervals for scenarios requiring higher data throughput, such as data-intensive transfers. The change includes a new API, an enum for priority levels, and platform-specific implementations to ensure correct behavior and error handling across different operating systems.

Highlights

  • New API for Connection Priority: Introduced requestConnectionPriority to allow tuning BLE connection intervals, specifically on Android, to improve data throughput.
  • Android-Specific Implementation: The requestConnectionPriority feature is fully implemented for Android, leveraging BluetoothGatt.requestConnectionPriority to offer 'balanced', 'highPerformance', and 'lowPower' options.
  • Cross-Platform Compatibility: For non-Android platforms (iOS/macOS, Linux, Web, Windows), calling requestConnectionPriority will throw a UniversalBleException with a notSupported error, as indicated by the new supportsConnectionPriorityApi capability flag.
  • Documentation and Versioning: The CHANGELOG.md and README.md have been updated to reflect the new feature and its usage, and the package version has been incremented to 1.3.0.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for requestConnectionPriority on Android, enabling developers to adjust BLE connection intervals for performance or power efficiency. The changes are well-implemented across the board, including the native Android code, the Dart API, and stubs for other platforms to ensure consistent behavior. Documentation has also been updated accordingly. I have one suggestion to enhance consistency in how errors are handled for unsupported platforms.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new requestConnectionPriority API to the universal_ble Flutter plugin to let Android apps request BLE connection parameter updates (balanced / highPerformance / lowPower), while providing consistent “not supported” behavior on non-Android platforms and updating docs/versioning.

Changes:

  • Introduce BleConnectionPriority and expose UniversalBle.requestConnectionPriority(...) (queued command, capability-gated).
  • Add platform-channel/Pigeon plumbing and stub implementations returning notSupported on non-Android platforms.
  • Implement Android-side BluetoothGatt.requestConnectionPriority(...), plus documentation and version/changelog updates.

Reviewed changes

Copilot reviewed 21 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
android/src/main/kotlin/com/navideck/universal_ble/UniversalBlePlugin.kt Implements requestConnectionPriority via BluetoothGatt.requestConnectionPriority.
android/src/main/kotlin/com/navideck/universal_ble/UniversalBle.g.kt Generated Pigeon interface + message handler wiring for the new method.
darwin/Classes/UniversalBlePlugin.swift Adds Apple-platform stub returning notSupported.
darwin/Classes/UniversalBle.g.swift Generated Pigeon protocol + channel setup for the new method.
windows/src/universal_ble_plugin.h Adds Windows plugin method declaration.
windows/src/universal_ble_plugin.cpp Adds Windows stub returning kNotSupported.
windows/src/generated/universal_ble.g.h Generated interface includes RequestConnectionPriority.
windows/src/generated/universal_ble.g.cpp Generated message handler for requestConnectionPriority.
lib/src/models/ble_connection_priority.dart New Dart enum representing connection priority.
lib/src/models/model_exports.dart Exports ble_connection_priority.dart.
lib/src/models/ble_capabilities.dart Adds supportsConnectionPriorityApi capability flag (Android-only).
lib/src/universal_ble_platform_interface.dart Adds requestConnectionPriority to the platform interface.
lib/src/universal_ble_pigeon/universal_ble_pigeon_channel.dart Adds Dart-side platform call + capability guard.
lib/src/universal_ble_pigeon/universal_ble.g.dart Generated Dart Pigeon channel method.
lib/src/universal_ble_linux/universal_ble_linux.dart Adds Linux stub throwing notSupported.
lib/src/universal_ble_web/universal_ble_web.dart Adds Web stub throwing notSupported.
lib/src/universal_ble.dart Adds the public UniversalBle.requestConnectionPriority API (queued).
pigeon/universal_ble.dart Adds Pigeon API definition for requestConnectionPriority.
test/universal_ble_test_mock.dart Updates test mock interface to include the new method.
example/lib/data/mock_universal_ble.dart Updates example mock to include the new method.
README.md Documents API support + adds usage section for connection priority.
CHANGELOG.md Adds 1.3.0 entry for the new API.
pubspec.yaml Bumps package version to 1.3.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fotiDim
Copy link
Copy Markdown
Contributor

fotiDim commented Mar 20, 2026

@raphael-bmec-co thank you for the PR. Could you please have a look into the AI comments?

@raphael-bmec-co
Copy link
Copy Markdown
Contributor Author

@fotiDim , yes sure. Would you mind having a quick look over the AI comments and sanity checking that they are valid and not hallucinations?

@fotiDim
Copy link
Copy Markdown
Contributor

fotiDim commented Mar 24, 2026

@raphael-bmec-co added my comments

@raphael-bmec-co
Copy link
Copy Markdown
Contributor Author

Thanks @fotiDim. Our team is working on this as we speak - we'll revert ASAP.

- 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
Fix requestConnectionPriority implementation
@aqeel-bmec-co
Copy link
Copy Markdown
Contributor

@fotiDim The comments above have been addressed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 24 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@fotiDim fotiDim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@fotiDim fotiDim merged commit f4b197f into Navideck:main Apr 1, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Connection Priority support on Android

4 participants