50 Commits

Author SHA1 Message Date
Tony 784c6f3929 Implement BLE peripheral support for Windows; add necessary structures and methods
Pull Request / test (push) Has been cancelled
Pull Request / pana (push) Has been cancelled
2026-05-08 07:50:32 +08:00
Tony 1d7108c9d0 Update Universal BLE Plugin for Peripheral Support and Code Generation
- Updated autogenerated files to reflect changes from Pigeon v26.3.4.
- Added new classes for UniversalBlePeripheralConfig, UniversalBlePeripheralService, UniversalBlePeripheralCharacteristic, UniversalBlePeripheralDescriptor, and UniversalBlePeripheralWriteEvent to handle peripheral configurations and events.
- Modified UniversalBlePlugin to implement methods for peripheral support, including StartPeripheral, StopPeripheral, UpdatePeripheralCharacteristicValue, and NotifyPeripheralCharacteristic, returning appropriate error messages for unsupported features on Windows.
- Updated HasPermissions method to include an additional parameter for Bluetooth advertising permissions.
- Adjusted method signatures and implementations across the plugin to accommodate new peripheral functionality.

Signed-off-by: Tony <tonylu@tony-cloud.com>
2026-05-08 03:36:12 +08:00
Raphael Smith f4b197f8ae 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 <aqeel@bmec.co>
Co-authored-by: aqeel-bmec-co <85945830+aqeel-bmec-co@users.noreply.github.com>
2026-04-01 21:15:39 +02:00
Usman Mehmood 3f4abdc5cd Fix Windows crash by handling WinRT exceptions in BLE callback paths (#217)
* Fix Windows crash by handling WinRT exceptions in BLE callback paths

This patch hardens the Windows plugin against unhandled native exceptions that could terminate the Flutter process during reconnect/disconnect flows.

- add shared `log_and_swallow` helpers for consistent native exception logging
- wrap `ConnectAsync` in defensive `try/catch` blocks, including per-service characteristic discovery
- guard `BluetoothLeDeviceConnectionStatusChanged` to prevent callback exceptions from escaping
- harden `CleanConnection` and `DisposeServices` when unregistering handlers/subscriptions
- add explicit error handling around CCCD writes in `SetNotifiableAsync`
- wrap `GattCharacteristicValueChanged` notification callback path in `try/catch`
- add `ResetState()` helper scaffold for full native BLE state cleanup on Windows

* Added missing log to an empty catch statement

* fix(windows): report native callback failures as disconnect events

- emit `OnConnectionChanged(..., false, error)` on WinRT exceptions
- clean connection state before reporting disconnect

* Update windows/src/universal_ble_plugin.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update windows/src/universal_ble_plugin.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update windows/src/helper/utils.h

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update windows/src/helper/utils.h

---------

Co-authored-by: Navideck Labs <130186950+navidecklabs@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-11 17:15:38 +01:00
Foti Dim 167d84f838 Always use custom scan filter for Windows 2026-02-10 11:44:52 +01:00
Rohit Sangwan 2f7f1f693d Add Android scan mode setting (#212)
* Add Android scan mode setting

* Format pigeon generated code

* format whole project

* Fix windows compilation because of generated code order

* Fix unwanted imports

* Add doc comment for AndroidOptions

* Update code doc
2026-01-21 15:32:40 +05:30
Rohit Sangwan dae2f5dc4d Add service-data in advertisements (#207)
* Add service-data in advertisements

* Fix windows serviceData parsing

* Resolve Ai comments

* Resolve Ai comments and validate service data

* Cleanup and Update changelog
2026-01-21 13:43:36 +05:30
Foti Dim 8557a46d05 Add auto-connect support (#206)
* Add autoConnect support

* Enhance autoConnect functionality for Bluetooth devices

- Added support for managing a set of auto-connect devices in both Android and iOS implementations.
- Updated connection and disconnection logic to handle auto-reconnect scenarios appropriately.
- Improved cleanup processes to prevent unwanted reconnections when devices are manually disconnected.

* Refactor connection button and add auto-reconnect toggle

- Updated the connection button layout for better UI consistency.
- Introduced an auto-reconnect toggle to manage automatic reconnections when devices become available.
- Enhanced connection and disconnection logic to respect the auto-connect setting.

* Update version to 1.2.0 and add CHANGELOG for new features

- Bumped version to 1.2.0.
- Added CHANGELOG.md detailing new features including support for `autoConnect` and UI updates for automatic reconnection.

* Improve readme

* Refactor variable naming for clarity in Bluetooth connection logic

- Changed variable name from `isAutoConnect` to `shouldAutoConnect` for better readability and understanding of its purpose in the connection state handling.

* Refactor connection handling in UniversalBlePlugin

- Simplified connection logic by always cleaning up internal state before sending connection change callbacks.
- Ensured GATT resources are only closed when autoConnect is disabled, allowing for better management of Bluetooth connections.

* Refactor disconnection handling in UniversalBlePlugin

- Introduced a new method `handlePeripheralDisconnection` to encapsulate disconnection logic, improving code readability and maintainability.
- Updated the `centralManager` methods to utilize the new disconnection handler, ensuring consistent behavior across connection state changes.

* Update darwin/Classes/UniversalBlePlugin.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Foti Dim <fotios.dimanidis@a2zebra.de>
Co-authored-by: Navideck Labs <130186950+navidecklabs@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-16 11:36:24 +05:30
EricKwok 1adfa9b485 Implement readRSSI on Android and Darwin (#203) 2026-01-05 17:49:55 +01:00
Foti Dim a5b6af6168 Enforce cxx_std_20 (#205)
* Enforce cxx_std_20

* Bump version

* Switch to private
2026-01-05 16:12:31 +01:00
Rohit Sangwan 97936046e0 Implement hasPermissions API (#201)
* Implement hasPermissions api

* Bump minimum MacOS version to 10.15

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-12 22:10:21 +01:00
Rohit Sangwan 89abb3bf03 Implement Logging (#199)
* Implement Logging

* Add timestamp in OnValueChanged

* improve web and linux logging

* Implement windows and format pigeon

* Fix windows build and unity log level

* Log commands with timestamp

* Fix code doc

* Remove unnecessary import

* Update docs

* Fix crash on windows 11 because of failed pairing

* Update changelog

* Fix native code formatting
2025-12-12 18:56:43 +05:30
Rohit Sangwan fa319416ef Implement timestamp in scanResult (#198)
* Implement timestamp in scanResult

* Update pigeon

* implement windows

* Update changelog

* Fix Swift formatting

* Remove android unused import

* Format pigeon generated file
2025-12-11 19:24:13 +05:30
Rohit Sangwan 3116962e8c Implement characteristic descriptor discovery (#196)
* Implement characteristic descriptor discovery

* Improve Darwin services discovery

* Minor mac fix

* Implement Windows support

* discover descriptors in DiscoverServicesAsync api on windows

* Add withDescriptors in discoverServices api

* Implement withDescriptors for Apple and Android

* Fix ai comment and format pigeon generated file

* Resolve Ai comment

* Capitalize API

* Handle empty services scenario

---------

Co-authored-by: Foti Dim <foti@navideck.com>
2025-12-10 11:36:04 +05:30
Rohit Sangwan 09bb22750a Improve disconnect api (#192)
* Improve disconnect api

* Get disconnection event on Web from callback

* Wait for disconnection result on calling disconnect

* Improve linux disconnection

* Update Changelog

* Fix Ai comments
2025-11-14 20:20:22 +05:30
Rohit Sangwan 970db165dd Implement requestPermission API (#190)
* Implement requestPermission api

* Update example ios podfile

* Update example windows dependencies

* Update Readme and Changelog

* Resolve Ai Comments

* Improve bluetooth permission handling

* Update Readme

* Improve readme

---------

Co-authored-by: Foti Dim <foti@navideck.com>
2025-11-13 17:22:17 +01:00
Rohit Sangwan 34b39597fd Implement isScanning api (#188)
* Implement isScanning api

* Improve IOS scanning api

* Update Readme and Changelog
2025-11-12 14:57:44 +01:00
Rohit Sangwan acfa3200ca Implement unified and type safe error messages (#186)
* Implement unified and type safe error messages

* Fix Apple error handling

* improve linux exception handling

* improve web exception handling

* fix window imports

* update pigeon generated files

* Fix compilaton issue

* Fix windows error parsing

* Fix windows compilation

* Improve error handling on dart side

* rename _wrapFuture to _executeWithErrorHandling

* Add pigeon generation script and format generated dart file

* Update changelog

* Update readme

---------

Co-authored-by: Foti Dim <foti@navideck.com>
2025-11-11 19:34:29 +01:00
Jon Salmon 3bc259524d fix: resolve BLE device names correctly on Windows (#174)
* fix: resolve BLE device names correctly on Windows

* Clear map on dispose
2025-08-20 09:05:30 +02:00
Rohit Sangwan 3ce064d20f Refactor native windows (#148)
* Error on windows scan

* Implement thread safe cache handling

* Fix start scan method

* Update windows/src/universal_ble_thread_safe.h

Co-authored-by: Foti Dim <foti@navideck.com>

* Refactor native Windows

* Fix guid parsing

* Fix FlutterError on Windows

* Fix Merge Conflicts

* Fix char subscription and store in characteristic struct instead of global map

---------

Co-authored-by: Foti Dim <fdimanidis@gmail.com>
Co-authored-by: Foti Dim <foti@navideck.com>
2025-03-19 11:23:22 +01:00
Foti Dim 0b51a5bbbd Fix error on Windows scan (#146)
* Error on windows scan

* Implement thread safe cache handling

* Fix start scan method

* Update windows/src/universal_ble_thread_safe.h

Co-authored-by: Foti Dim <foti@navideck.com>

---------

Co-authored-by: Rohit Sangwan <rohitsangwan647@gmail.com>
2025-03-18 15:41:28 +05:30
Rohit Sangwan f0c38f7273 Fix Windows crash on start or stop scan (#143)
* Fix Windows crash on start or stop scan

* Fix crash on stop scan and cleanup

* Update Changelog

* Cleanups
2025-02-25 13:43:51 +01:00
Rohit Sangwan bc19a653dd Fix: Unable to establish connection on channel when hot restart (#142)
* Fix: Unable to establish connection on channel when hot restart

* Update Changelog
2025-02-21 19:27:54 +05:30
Rohit Sangwan 6cc43ccc86 Fix crash on Windows when calling pair APIs with an unknown deviceId (#141)
* Fix crash on Windows when call few apis with an unknown deviceId

* Update Changelog

* Bump Version
2025-02-20 12:28:33 +01:00
Rohit Sangwan 1292199426 Add API to disable Bluetooth (#113)
* Add api to disable Bluetooth

* Implement Android support

* Fix apple build

* Update Readme

* Combine rows

---------

Co-authored-by: Foti Dim <fdimanidis@gmail.com>
2024-12-09 21:18:01 +05:30
Rohit Sangwan 7187768bd0 Rename hasCustomFilter to usesCustomFilters (#115) 2024-12-09 16:44:48 +01:00
Rohit Sangwan 437eca70af Fix Windows filter with services (#111)
* Fix Windows filter with services

* Fix comment typos

---------

Co-authored-by: Foti Dim <fdimanidis@gmail.com>
2024-12-09 16:32:42 +01:00
Rohit Sangwan bbf9703303 Fix Windows Bluetooth availability state in Release build (#112)
* Fix Windows Bluetooth availability state in Release build

* Make initialized private

---------

Co-authored-by: Foti Dim <fdimanidis@gmail.com>
2024-12-09 16:08:12 +01:00
fotidim db75c4c71e Increase pin entry window size on Windows 10 2024-11-28 21:56:49 +01:00
Rohit Sangwan e4b6bd74ba Rename filterMfdList to manufacturerDataFilters and replace mfd with msd 2024-10-03 11:59:14 +05:30
Rohit Sangwan b77d0aaeb4 Add error in connection updates (#89)
* Add error in connection updates

* implement windows

* Update changelog and Docs

* minor fix in connect()

* Add default timeout in connect

* Document new pair and connect API

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

* remove import

* Rename PairingException and update Exception doc

* Update changelog

* Update comments

---------

Co-authored-by: Foti Dim <fdimanidis@gmail.com>
2024-09-26 23:08:25 +02:00
Rohit Sangwan 7dc22c58a5 Improve scan filter api (#78)
* Improve scan filter api

* Implement Windows filters

* Add manufacturerDataList and deprecate manufacturerData

* Fix Windows

* Update Readme and changelog

* Remove import

* Fix Linux

* Update readme and changelog

* Cleanup Todo

* Improve ManufacturerData

* Rename webConfig and Manufacturer.data

* Return false for receivesAdvertisements on Linux/Web

* Add delay in discoverServices on Linux

* Remove import

* Update changelog

---------

Co-authored-by: fotidim <foti@navideck.com>
2024-09-16 23:43:51 +02:00
Foti Dim 40819d5796 Return pair result 2024-08-12 21:15:56 +02:00
Rohit Sangwan 8d0cfe98d9 Add connecting and disconnecting states to BleConnectionState (#54)
* Add connecting and disconnecting state

* Replace BleConnectionState with boolean in onConnectionChanged callback

* Improve Docs and Changelog

* Implement GetConnectionState in Windows

* Update CHANGELOG.md

Co-authored-by: Foti Dim <foti@navideck.com>

* Add  code level doc of connectionState getter

---------

Co-authored-by: Foti Dim <foti@navideck.com>
2024-06-20 20:47:02 +02:00
Foti Dim 6361574b77 Add connection properties in BleDevice (#50)
* Rename to BleDevice

* Add isConnected property

* Make isConnected true

* Add isConnected api

* Implement Windows

* Merge add-isConnected-api

* Rename getConnectedDevices to getSystemDevices

* Add code level Doc for isConnected

* Add isPaired

* Revert isPaired

* Add isSystemDevice property in BleDevice

* Return enum instead of bool

---------

Co-authored-by: Rohit Sangwan <rohitsangwan647@gmail.com>
2024-06-13 16:14:54 +02:00
Rohit Sangwan b74191bb97 Implement pairing with dialog on windows (#46)
* Implement pairing with dialog on windows

* Minor fix

* Add pin pairing request for windows 10

* Implement native windows dialog for asking pin pairing

* Cleanups

* Improve pairing dialog ui

* Use PairAsync for Windows 11

* Fix OK button text

* Improve pin entry layout

Co-authored-by: Rohit Sangwan <rohitsangwan647@gmail.com>

* Dialog adjustments

* Make dialog non resizable

* Make window topmost

* Final adjustments

* Update changelog

* Release dialog resources properly

* Release dialog resources properly

* Remove duplicate import

* Minor Fix

---------

Co-authored-by: fotidim <foti@navideck.com>
2024-06-11 12:28:25 +02:00
Rohit Sangwan 05697b7d30 Improve setNotifiation completion (#42)
* Improve setNotifiation completion

* Implement Windows

* Minor android fixes

* Few more fixes

* Update changelog

---------

Co-authored-by: Foti Dim <fdimanidis@gmail.com>
2024-05-10 12:59:10 +02:00
Rohit Sangwan b07a8888e0 Fix windows scan filter (#41)
* Fix windows scan filter

* Bump version and add changelog

---------

Co-authored-by: fotidim <foti@navideck.com>
2024-05-10 09:57:04 +02:00
Foti Dim fef4e8526b Improve Apple, Android and Windows (#40)
* Cleanup connection

* Reverse search list

* Bump version

* Fix Android serviceUuids in scanResults

* Fix typo

* Improve cleanup on apple

* Improve Apple reconnection and service discovery

* Persist long scan result name on Windows

Co-authored-by: navidecklabs <navidecklabs@users.noreply.github.com>

* Update changelog

---------

Co-authored-by: Rohit Sangwan <rohitsangwan647@gmail.com>
Co-authored-by: navidecklabs <navidecklabs@users.noreply.github.com>
2024-05-09 11:48:32 +02:00
Foti Dim 3be945c3d5 Improve manufacturer data discovery on Windows (#38)
* Improve manufacturer data discovery on Windows

* Switch pairing protection level to encrypted in Windows

* Minor UI improvement in example app

* Update windows/src/universal_ble_plugin.h

* Remove minimum DevicePairingProtectionLevel

* Improve logging

* Bump version

---------

Co-authored-by: Rohit Sangwan <rohitsangwan647@gmail.com>
2024-05-02 00:09:44 +02:00
Rohit Sangwan 9e51e9e951 Fix discover services on Windows (#32)
* Fix discover services on Windows

* Bump version

---------

Co-authored-by: fotidim <foti@navideck.com>
2024-03-28 13:08:55 +05:30
Rohit Sangwan 870defea86 Update readme and improve logs (#28)
* Update readme and improve logs

* Apply suggestions from code review

Co-authored-by: Foti Dim <foti@navideck.com>

* Add changelog

* Update Readme

* Update lib/src/universal_ble_web/universal_ble_web.dart

* Improve readme

* Update README.md

* Keep web section

---------

Co-authored-by: Foti Dim <foti@navideck.com>
2024-03-19 09:22:54 +01:00
Rohit Sangwan 1a0e48ba1a Add manufacturer data filtering (#23)
* Add manufacturer data filtering

* Implement manufacturer data filter in windows

* Fix manufacturerData filtering on windows

* Fix linux

* Clean comments

---------

Co-authored-by: Foti Dim <fdimanidis@gmail.com>
2024-03-18 18:44:44 +01:00
Foti Dim 580fca6e4a Fix wrong manufacturer data in release mode (#24)
* Fix wrong manufacturer data in release mode

* Improve code

* fix manufacturer data for little endian

* Minor fix

---------

Co-authored-by: Rohit Sangwan <rohitsangwan647@gmail.com>
2024-03-18 18:16:16 +01:00
Rohit Sangwan e22a3ddf99 Fix windows crash when no bluetooth adapter available (#20) 2024-03-13 13:03:42 +01:00
Rohit Sangwan 1f7ba287ef Implement ScanFilter (#17)
* Implement ScanFilter

* Add windows implementation

* Fix Linux and cleanups

* Update Readme, Changelog and Version

* Minor fixes from AI comments

* Fix windows crash and update pigeon

* Fix UUID parsing

* Apply suggestions from code review

Co-authored-by: Foti Dim <foti@navideck.com>

---------

Co-authored-by: Foti Dim <foti@navideck.com>
2024-03-05 22:37:14 +05:30
Rohit Sangwan 7e47be374b Fix windows release build compilation (#16) 2024-03-04 15:19:47 +05:30
Rohit Sangwan 663bc76dfe Improve Windows and Linux error handling (#12)
* Improve windows and linux error handeling

* Send proper error code from windows for write command

* Fix Linux

* Fix getConnectedDevices on windows

---------

Co-authored-by: fotidim <fdimanidis@gmail.com>
Co-authored-by: fotidim <foti@navideck.com>
2024-02-16 19:36:36 +01:00
Rohit Sangwan ed3852a5c9 Improve windows device name discovery (#4)
* Improve windows device name discovery

* Imrove classes and folders structuring

* rename generated files

* Improve windows threads and other fixes

* More optimizations

* Cleanups

* Update .vscode/settings.json

Co-authored-by: Foti Dim <foti@navideck.com>

* Resolve comments

* Performance improvements

---------

Co-authored-by: Foti Dim <foti@navideck.com>
Co-authored-by: Foti Dim <fdimanidis@gmail.com>
2024-02-02 12:10:53 +01:00
Foti Dim 1c21373478 Initial commit 2024-01-24 14:23:49 +01:00