* 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>
- Introduced a new method `_getActiveFilterCount` to calculate the number of active filters.
- Updated the filter button to show a badge with the active filter count.
- Changed the clear filter button icon for better clarity.
- Enhanced the hint style in the scan filter widget for improved visibility.
- Added a new `prefs_async.dart` file to encapsulate the usage of `SharedPreferencesAsync`.
- Updated `ScanController`, `StorageService`, and `ScannerScreen` to utilize the new async preferences methods, enhancing performance and code clarity.
- Modified `devtools_options.yaml` to enable the `shared_preferences` extension.
- Refactored the `FlashOnUpdateWidget` to improve the outline animation and added a customizable border radius.
- Adjusted the favorite services loading mechanism in `PeripheralDetailPage` to be asynchronous, ensuring better state management.
- Removed the tooltip for Bluetooth availability from ScannerScreen and integrated the BleAvailabilityIcon directly into the AppDrawer.
- Updated the AppDrawer to accept Bluetooth availability state and a callback for state changes.
- Simplified button labels in ScannerScreen and ScannedDevicesPlaceholderWidget for clarity.
- Adjusted padding for buttons to enhance UI consistency.
- Introduced an enum `ScanOrder` to define sorting options for scanned devices.
- Implemented logic to save and retrieve the selected scan order from shared preferences.
- Added a popup menu for users to select the sorting method (Last Seen, Name, RSSI).
- Updated the device list display to reflect the selected sorting order, enhancing user experience.
- Added a new method `_onScanFilterApplied` to handle the application of scan filters, which updates the state and clears device lists.
- Refactored the filter application logic in the bottom sheet to utilize the new method for better code organization.
- Ensured that device lists are cleared when a new filter is applied and scanning is stopped if currently active.
- Converted ScannedItemWidget from StatelessWidget to StatefulWidget to manage state and update the UI dynamically.
- Added a timer to refresh the display of the last advertisement timestamp.
- Improved the formatting of the last seen advertisement message for better clarity.
* - Added support for BLE scanning from background services on Android.
- Enhanced `PermissionHandler` to be activity-aware, allowing silent success for already granted permissions when no activity is available.
- Updated README with best practices for requesting permissions in foreground before background operations.
* Simplify implementation
* Improve example app
- Introduced utility functions for sorting BLE services and filtering characteristics based on properties.
- Updated the peripheral detail page to support reading all characteristics and improved value formatting for better readability.
- Added navigation functionality for adjacent characteristics and integrated property filters in the services list widget.
- Enhanced the services side widget to manage selected properties and provide a clearer UI for service interactions.
- Implemented copy functionality for logs and improved overall user experience in the peripheral details section.
* Remove expandable
* Automatically start scanning on launch
* Show loading indicator for discovering services
* Decrease the height of TextFormField
* Add service-data in advertisements
* Fix windows serviceData parsing
* Resolve Ai comments
* Resolve Ai comments and validate service data
* Cleanup and Update changelog
* Update company identifier handling and enhance scanning features
- Updated `pubspec.lock` to version 1.2.0 and added `yaml` dependency.
- Introduced `CompanyIdentifierService` for loading and querying company identifiers from a new YAML file.
- Enhanced scanning functionality to support filtering by company names and IDs.
- Updated UI components to display company names alongside manufacturer data in scanned items.
- Improved search functionality to include company names in the filter criteria.
* Address AI comments
* Address AI comments
* Allow searching by company id
* Remove redundant loading state update in CompanyIdentifierService
* Enhance company ID parsing in CompanyIdentifierService
- Updated the `_parseCompanyId` method to support additional formats for company IDs, including non-prefixed strings interpreted as decimal or hexadecimal based on their content.
- Improved parsing logic to first attempt hexadecimal conversion if the string contains hex characters, enhancing flexibility in input handling.
* Update the peripheral detail page to format and display discovered services more clearly, including characteristics.
* Address AI comments
* Refactor characteristic display format in peripheral detail page for improved clarity
- Added logic to differentiate between read and notify/indicate errors in the `didUpdateValueFor` method of `UniversalBlePlugin`.
- Improved error handling by preventing duplicate logging for read operations while maintaining appropriate logging for notify/indicate errors.
- Bump version to 1.2.0 in pubspec.lock.
- Enhance ScannerScreen with a Bluetooth availability tooltip and improved search filter UI.
- Refactor AppDrawer to include a queue type selection feature.
- Update ScannedDevicesPlaceholderWidget to include a 'Start Scan' button for better user interaction.
- Improve overall layout and styling for better user experience.
* 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>
- Implemented loading and saving of scan filters (services, name prefix, manufacturer data, and search term) using SharedPreferences.
- Added functionality to apply filters from the loaded preferences.
- Updated the UI to save filters when they change or when the search is cleared.
* Improve example app ui
* Store favorite services in local storage
* Use Text instead of SelectableText
* Improve colors
* Fix flutter analyzer issues
* Revert example app minimum sdk requirement
* Implement hasPermission api and improve ui flow
* More ui improvements
* Improve ScannedItem ui
* Improve control ui
* Change color theme to blue
* Minor improvements wip
* improve responsive ui and flow
* More improvements
* More improvements
* Update Mac podfile
* Fix home page scroll view
* Update app and package name
* Revert changelog
* Resolve Ai comments
---------
Co-authored-by: Foti Dim <foti@navideck.com>
- Clarified MTU request behavior and platform limitations in README.md.
- Added best practices for MTU management in cross-platform BLE applications.
- Enhanced documentation for `requestMtu` method in UniversalBle and BleDeviceExtension to reflect best-effort nature of MTU requests and platform-specific behaviors.
Co-authored-by: Foti Dim <foti@navideck.com>