Files
universal_ble/test/universal_ble_test_mock.dart
T
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

106 lines
2.2 KiB
Dart

import 'dart:typed_data';
import 'package:universal_ble/universal_ble.dart';
abstract class UniversalBlePlatformMock extends UniversalBlePlatform {
@override
Future<void> connect(String deviceId,
{bool autoConnect = false, Duration? connectionTimeout}) {
throw UnimplementedError();
}
@override
Future<bool> disableBluetooth() {
throw UnimplementedError();
}
@override
Future<void> disconnect(String deviceId) {
throw UnimplementedError();
}
@override
Future<List<BleService>> discoverServices(
String deviceId, bool withDescriptors) {
throw UnimplementedError();
}
@override
Future<bool> enableBluetooth() {
throw UnimplementedError();
}
@override
Future<AvailabilityState> getBluetoothAvailabilityState() {
throw UnimplementedError();
}
@override
Future<BleConnectionState> getConnectionState(String deviceId) {
throw UnimplementedError();
}
@override
Future<List<BleDevice>> getSystemDevices(List<String>? withServices) {
throw UnimplementedError();
}
@override
Future<bool> isPaired(String deviceId) {
throw UnimplementedError();
}
@override
Future<bool> pair(String deviceId) {
throw UnimplementedError();
}
@override
Future<Uint8List> readValue(
String deviceId, String service, String characteristic,
{Duration? timeout}) {
throw UnimplementedError();
}
@override
Future<int> requestMtu(String deviceId, int expectedMtu) {
throw UnimplementedError();
}
@override
Future<void> setNotifiable(String deviceId, String service,
String characteristic, BleInputProperty bleInputProperty) {
throw UnimplementedError();
}
@override
Future<void> startScan(
{ScanFilter? scanFilter, PlatformConfig? platformConfig}) {
throw UnimplementedError();
}
@override
Future<void> stopScan() {
throw UnimplementedError();
}
@override
Future<void> unpair(String deviceId) {
throw UnimplementedError();
}
@override
Future<void> writeValue(
String deviceId,
String service,
String characteristic,
Uint8List value,
BleOutputProperty bleOutputProperty) {
throw UnimplementedError();
}
@override
Future<bool> isScanning() {
throw UnimplementedError();
}
}