diff --git a/analysis_options.yaml b/analysis_options.yaml index 6333ee51..15587653 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -27,8 +27,10 @@ linter: # - diagnostic_describe_all_properties -- DISABLED: experimental feature - empty_statements - hash_and_equals - - invariant_booleans + # - invariant_booleans + - iterable_contains_unrelated_type - collection_methods_unrelated_type + - list_remove_unrelated_type - literal_only_boolean_expressions - no_adjacent_strings_in_list - no_duplicate_case_values diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 986ee288..38179f0e 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 33 + compileSdkVersion 34 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -45,7 +45,7 @@ android { defaultConfig { applicationId "com.signify.hue.reactivebleexample" minSdkVersion 21 - targetSdkVersion 33 + targetSdkVersion 34 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/example/android/build.gradle b/example/android/build.gradle index 016184d1..2353f21a 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -6,7 +6,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:8.0.2' + classpath 'com.android.tools.build:gradle:8.7.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 89e56bdb..09523c0e 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ -#Fri Jun 23 08:50:38 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip diff --git a/example/devtools_options.yaml b/example/devtools_options.yaml new file mode 100644 index 00000000..fa0b357c --- /dev/null +++ b/example/devtools_options.yaml @@ -0,0 +1,3 @@ +description: This file stores settings for Dart & Flutter DevTools. +documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states +extensions: diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 6d5be2f1..20355336 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -30,4 +30,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011 -COCOAPODS: 1.14.3 +COCOAPODS: 1.15.2 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 3b3f27a7..ab9d9ba4 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -33,6 +33,7 @@ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 2DC939A6C6230516B6561DA7 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 3AB1B41129E6FF160046DF89 /* Info-Release.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-Release.plist"; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -44,7 +45,7 @@ 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info-Debug.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-Debug.plist"; sourceTree = ""; }; A1AB08F7B02CE763EEA8E83F /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -93,10 +94,11 @@ 97C146F01CF9000F007C117D /* Runner */ = { isa = PBXGroup; children = ( + 3AB1B41129E6FF160046DF89 /* Info-Release.plist */, 97C146FA1CF9000F007C117D /* Main.storyboard */, 97C146FD1CF9000F007C117D /* Assets.xcassets */, 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, - 97C147021CF9000F007C117D /* Info.plist */, + 97C147021CF9000F007C117D /* Info-Debug.plist */, 97C146F11CF9000F007C117D /* Supporting Files */, 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, @@ -166,7 +168,6 @@ TargetAttributes = { 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; - DevelopmentTeam = 29DK8LS8B3; LastSwiftMigration = 0910; }; }; @@ -428,7 +429,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 29DK8LS8B3; + DEVELOPMENT_TEAM = 5KK9N97KX3; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -443,7 +444,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.signify.hue.reactivebleExample; + PRODUCT_BUNDLE_IDENTIFIER = com.signify.hue.tangoReactiveBleExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift index 70693e4a..b6363034 100644 --- a/example/ios/Runner/AppDelegate.swift +++ b/example/ios/Runner/AppDelegate.swift @@ -1,7 +1,7 @@ import UIKit import Flutter -@UIApplicationMain +@main @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, diff --git a/example/lib/main.dart b/example/lib/main.dart index 82e028f0..97e2bf86 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; +import 'package:flutter_reactive_ble_example/src/ble/ble_device_bond_monitor.dart'; import 'package:flutter_reactive_ble_example/src/ble/ble_device_connector.dart'; import 'package:flutter_reactive_ble_example/src/ble/ble_device_interactor.dart'; import 'package:flutter_reactive_ble_example/src/ble/ble_scanner.dart'; @@ -15,12 +16,14 @@ const _themeColor = Colors.lightGreen; void main() { WidgetsFlutterBinding.ensureInitialized(); - final _ble = FlutterReactiveBle(); + final _ble = FlutterReactiveBle.withRestorationKey('someRestorationKey'); final _bleLogger = BleLogger(ble: _ble); final _scanner = BleScanner(ble: _ble, logMessage: _bleLogger.addToLog); final _monitor = BleStatusMonitor(_ble); + final _bondMonitor = BleDeviceBondMonitor(_ble); final _connector = BleDeviceConnector( ble: _ble, + bondMonitor: _bondMonitor, logMessage: _bleLogger.addToLog, ); final _serviceDiscoverer = BleDeviceInteractor( @@ -39,6 +42,7 @@ void main() { Provider.value(value: _connector), Provider.value(value: _serviceDiscoverer), Provider.value(value: _bleLogger), + Provider.value(value: _bondMonitor), StreamProvider( create: (_) => _scanner.state, initialData: const BleScannerState( @@ -50,6 +54,10 @@ void main() { create: (_) => _monitor.state, initialData: BleStatus.unknown, ), + StreamProvider( + create: (_) => _bondMonitor.state, + initialData: DeviceBondState.unknown, + ), StreamProvider( create: (_) => _connector.state, initialData: const ConnectionStateUpdate( diff --git a/example/lib/src/ble/ble_device_bond_monitor.dart b/example/lib/src/ble/ble_device_bond_monitor.dart new file mode 100644 index 00000000..a79b2a1b --- /dev/null +++ b/example/lib/src/ble/ble_device_bond_monitor.dart @@ -0,0 +1,34 @@ +import 'dart:async'; + +import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; +import 'package:flutter_reactive_ble_example/src/ble/reactive_state.dart'; + +class BleDeviceBondMonitor implements ReactiveState { + BleDeviceBondMonitor(this._ble); + + final FlutterReactiveBle _ble; + + @override + Stream get state => _bondStateController.stream; + + final StreamController _bondStateController = + StreamController(); + + StreamSubscription? _bondStateSubscription; + + void startMonitoringDevice(String deviceId) { + _bondStateSubscription ??= _ble.bondUpdateStream + .where((update) => update.deviceId == deviceId) + .map((update) => update.bondState) + .listen(_bondStateController.add); + } + + void stopMontoringDevice(String deviceId) { + _bondStateSubscription?.cancel(); + _bondStateSubscription = null; + } + + Future dispose() async { + await _bondStateController.close(); + } +} diff --git a/example/lib/src/ble/ble_device_connector.dart b/example/lib/src/ble/ble_device_connector.dart index 536ff8b0..642a41e1 100644 --- a/example/lib/src/ble/ble_device_connector.dart +++ b/example/lib/src/ble/ble_device_connector.dart @@ -1,16 +1,20 @@ import 'dart:async'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; +import 'package:flutter_reactive_ble_example/src/ble/ble_device_bond_monitor.dart'; import 'package:flutter_reactive_ble_example/src/ble/reactive_state.dart'; class BleDeviceConnector extends ReactiveState { BleDeviceConnector({ required FlutterReactiveBle ble, + required BleDeviceBondMonitor bondMonitor, required void Function(String message) logMessage, }) : _ble = ble, + _bondMonitor = bondMonitor, _logMessage = logMessage; final FlutterReactiveBle _ble; + final BleDeviceBondMonitor _bondMonitor; final void Function(String message) _logMessage; @override @@ -22,6 +26,8 @@ class BleDeviceConnector extends ReactiveState { late StreamSubscription _connection; Future connect(String deviceId) async { + _bondMonitor.startMonitoringDevice(deviceId); + _logMessage('Start connecting to $deviceId'); _connection = _ble.connectToDevice(id: deviceId).listen( (update) { @@ -35,6 +41,8 @@ class BleDeviceConnector extends ReactiveState { } Future disconnect(String deviceId) async { + _bondMonitor.stopMontoringDevice(deviceId); + try { _logMessage('disconnecting to device: $deviceId'); await _connection.cancel(); diff --git a/example/lib/src/ui/device_detail/device_interaction_tab.dart b/example/lib/src/ui/device_detail/device_interaction_tab.dart index 02a2fb98..3c1303f6 100644 --- a/example/lib/src/ui/device_detail/device_interaction_tab.dart +++ b/example/lib/src/ui/device_detail/device_interaction_tab.dart @@ -20,14 +20,19 @@ class DeviceInteractionTab extends StatelessWidget { final DiscoveredDevice device; @override - Widget build(BuildContext context) => Consumer3( - builder: (_, deviceConnector, connectionStateUpdate, serviceDiscoverer, __) => _DeviceInteractionTab( + Widget build(BuildContext context) => Consumer4( + builder: (_, deviceConnector, bondState, connectionStateUpdate, + serviceDiscoverer, __) => + _DeviceInteractionTab( viewModel: DeviceInteractionViewModel( deviceId: device.id, + bondState: bondState, connectableStatus: device.connectable, connectionStatus: connectionStateUpdate.connectionState, deviceConnector: deviceConnector, - discoverServices: () => serviceDiscoverer.discoverServices(device.id), + discoverServices: () => + serviceDiscoverer.discoverServices(device.id), readRssi: () => serviceDiscoverer.readRssi(device.id), ), ), @@ -40,6 +45,7 @@ class DeviceInteractionViewModel extends $DeviceInteractionViewModel { const DeviceInteractionViewModel({ required this.deviceId, required this.connectableStatus, + required this.bondState, required this.connectionStatus, required this.deviceConnector, required this.discoverServices, @@ -48,6 +54,7 @@ class DeviceInteractionViewModel extends $DeviceInteractionViewModel { final String deviceId; final Connectable connectableStatus; + final DeviceBondState bondState; final DeviceConnectionState connectionStatus; final BleDeviceConnector deviceConnector; final Future Function() readRssi; @@ -55,7 +62,8 @@ class DeviceInteractionViewModel extends $DeviceInteractionViewModel { @CustomEquality(Ignore()) final Future> Function() discoverServices; - bool get deviceConnected => connectionStatus == DeviceConnectionState.connected; + bool get deviceConnected => + connectionStatus == DeviceConnectionState.connected; void connect() { deviceConnector.connect(deviceId); @@ -110,7 +118,8 @@ class _DeviceInteractionTabState extends State<_DeviceInteractionTab> { delegate: SliverChildListDelegate.fixed( [ Padding( - padding: const EdgeInsetsDirectional.only(top: 8.0, bottom: 16.0, start: 16.0), + padding: const EdgeInsetsDirectional.only( + top: 8.0, bottom: 16.0, start: 16.0), child: Text( "ID: ${widget.viewModel.deviceId}", style: const TextStyle(fontWeight: FontWeight.bold), @@ -137,27 +146,39 @@ class _DeviceInteractionTabState extends State<_DeviceInteractionTab> { style: const TextStyle(fontWeight: FontWeight.bold), ), ), + Padding( + padding: const EdgeInsetsDirectional.only(start: 16.0), + child: Text( + "Bond status: ${widget.viewModel.bondState}", + style: const TextStyle(fontWeight: FontWeight.bold), + ), + ), Padding( padding: const EdgeInsets.only(top: 16.0), child: Wrap( alignment: WrapAlignment.spaceEvenly, children: [ ElevatedButton( - onPressed: !widget.viewModel.deviceConnected ? widget.viewModel.connect : null, + onPressed: !widget.viewModel.deviceConnected + ? widget.viewModel.connect + : null, child: const Text("Connect"), ), ElevatedButton( - onPressed: widget.viewModel.deviceConnected ? widget.viewModel.disconnect : null, + onPressed: widget.viewModel.deviceConnected + ? widget.viewModel.disconnect + : null, child: const Text("Disconnect"), ), ElevatedButton( - onPressed: widget.viewModel.deviceConnected ? discoverServices : null, + onPressed: widget.viewModel.deviceConnected + ? discoverServices + : null, child: const Text("Discover Services"), ), ElevatedButton( - onPressed: widget.viewModel.deviceConnected - ? readRssi - : null, + onPressed: + widget.viewModel.deviceConnected ? readRssi : null, child: const Text("Get RSSI"), ), ], @@ -222,7 +243,8 @@ class _ServiceDiscoveryListState extends State<_ServiceDiscoveryList> { Widget _characteristicTile(Characteristic characteristic) => ListTile( onTap: () => showDialog( context: context, - builder: (context) => CharacteristicInteractionDialog(characteristic: characteristic), + builder: (context) => + CharacteristicInteractionDialog(characteristic: characteristic), ), title: Text( '${characteristic.id}\n(${_characteristicSummary(characteristic)})', @@ -253,7 +275,9 @@ class _ServiceDiscoveryListState extends State<_ServiceDiscoveryList> { ), Column( mainAxisSize: MainAxisSize.min, - children: service.characteristics.map(_characteristicTile).toList(), + children: service.characteristics + .map(_characteristicTile) + .toList(), ), ], ), diff --git a/example/lib/src/ui/device_detail/device_interaction_tab.g.dart b/example/lib/src/ui/device_detail/device_interaction_tab.g.dart index b4f78b7c..f704061d 100644 --- a/example/lib/src/ui/device_detail/device_interaction_tab.g.dart +++ b/example/lib/src/ui/device_detail/device_interaction_tab.g.dart @@ -11,6 +11,7 @@ abstract class $DeviceInteractionViewModel { String get deviceId; Connectable get connectableStatus; + DeviceBondState get bondState; DeviceConnectionState get connectionStatus; BleDeviceConnector get deviceConnector; Future Function() get readRssi; @@ -19,6 +20,7 @@ abstract class $DeviceInteractionViewModel { DeviceInteractionViewModel copyWith({ String? deviceId, Connectable? connectableStatus, + DeviceBondState? bondState, DeviceConnectionState? connectionStatus, BleDeviceConnector? deviceConnector, Future Function()? readRssi, @@ -27,6 +29,7 @@ abstract class $DeviceInteractionViewModel { DeviceInteractionViewModel( deviceId: deviceId ?? this.deviceId, connectableStatus: connectableStatus ?? this.connectableStatus, + bondState: bondState ?? this.bondState, connectionStatus: connectionStatus ?? this.connectionStatus, deviceConnector: deviceConnector ?? this.deviceConnector, readRssi: readRssi ?? this.readRssi, @@ -38,6 +41,7 @@ abstract class $DeviceInteractionViewModel { final change = DeviceInteractionViewModel$Change._( this.deviceId, this.connectableStatus, + this.bondState, this.connectionStatus, this.deviceConnector, this.readRssi, @@ -47,6 +51,7 @@ abstract class $DeviceInteractionViewModel { return DeviceInteractionViewModel( deviceId: change.deviceId, connectableStatus: change.connectableStatus, + bondState: change.bondState, connectionStatus: change.connectionStatus, deviceConnector: change.deviceConnector, readRssi: change.readRssi, @@ -56,7 +61,7 @@ abstract class $DeviceInteractionViewModel { @override String toString() => - "DeviceInteractionViewModel(deviceId: $deviceId, connectableStatus: $connectableStatus, connectionStatus: $connectionStatus, deviceConnector: $deviceConnector, readRssi: $readRssi, discoverServices: $discoverServices)"; + "DeviceInteractionViewModel(deviceId: $deviceId, connectableStatus: $connectableStatus, bondState: $bondState, connectionStatus: $connectionStatus, deviceConnector: $deviceConnector, readRssi: $readRssi, discoverServices: $discoverServices)"; @override // ignore: avoid_equals_and_hash_code_on_mutable_classes @@ -65,6 +70,7 @@ abstract class $DeviceInteractionViewModel { other.runtimeType == runtimeType && deviceId == other.deviceId && connectableStatus == other.connectableStatus && + bondState == other.bondState && connectionStatus == other.connectionStatus && deviceConnector == other.deviceConnector && readRssi == other.readRssi && @@ -76,6 +82,7 @@ abstract class $DeviceInteractionViewModel { var result = 17; result = 37 * result + deviceId.hashCode; result = 37 * result + connectableStatus.hashCode; + result = 37 * result + bondState.hashCode; result = 37 * result + connectionStatus.hashCode; result = 37 * result + deviceConnector.hashCode; result = 37 * result + readRssi.hashCode; @@ -88,6 +95,7 @@ class DeviceInteractionViewModel$Change { DeviceInteractionViewModel$Change._( this.deviceId, this.connectableStatus, + this.bondState, this.connectionStatus, this.deviceConnector, this.readRssi, @@ -96,6 +104,7 @@ class DeviceInteractionViewModel$Change { String deviceId; Connectable connectableStatus; + DeviceBondState bondState; DeviceConnectionState connectionStatus; BleDeviceConnector deviceConnector; Future Function() readRssi; @@ -119,6 +128,12 @@ class DeviceInteractionViewModel$ { connectableStatus: connectableStatus), ); + static final bondState = Lens( + (bondStateContainer) => bondStateContainer.bondState, + (bondStateContainer, bondState) => + bondStateContainer.copyWith(bondState: bondState), + ); + static final connectionStatus = Lens( (connectionStatusContainer) => connectionStatusContainer.connectionStatus, diff --git a/example/pubspec.lock b/example/pubspec.lock index 19487965..3c7bf9d5 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -318,26 +318,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" url: "https://pub.dev" source: hosted - version: "10.0.0" + version: "10.0.5" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.5" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.1" lints: dependency: transitive description: @@ -366,18 +366,18 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec url: "https://pub.dev" source: hosted - version: "0.8.0" + version: "0.11.1" meta: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.15.0" mime: dependency: transitive description: @@ -553,10 +553,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.2" timing: dependency: transitive description: @@ -585,10 +585,10 @@ packages: dependency: transitive description: name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "13.0.0" + version: "14.2.5" watcher: dependency: transitive description: @@ -623,4 +623,4 @@ packages: version: "3.1.2" sdks: dart: ">=3.3.0 <4.0.0" - flutter: ">=2.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/packages/flutter_reactive_ble/lib/src/connected_device_operation.dart b/packages/flutter_reactive_ble/lib/src/connected_device_operation.dart index da007bd7..2a1aa0e8 100644 --- a/packages/flutter_reactive_ble/lib/src/connected_device_operation.dart +++ b/packages/flutter_reactive_ble/lib/src/connected_device_operation.dart @@ -17,6 +17,11 @@ abstract class ConnectedDeviceOperation { required List value, }); + Stream> attachToCharacteristicSubscription( + CharacteristicInstance characteristic, + Future isDisconnected, + ); + Stream> subscribeToCharacteristic( CharacteristicInstance characteristic, Future isDisconnected, @@ -98,6 +103,29 @@ class ConnectedDeviceOperationImpl implements ConnectedDeviceOperation { return autosubscribingRepeater.stream; } + @override + Stream> attachToCharacteristicSubscription( + CharacteristicInstance characteristic, + Future isDisconnected, + ) { + final specificCharacteristicValueStream = characteristicValueStream + .where((update) => update.characteristic == characteristic) + .map((update) => update.result.dematerialize()); + + final autosubscribingRepeater = Repeater>.broadcast( + onListenEmitFrom: () => specificCharacteristicValueStream, + onCancel: () => _blePlatform + .stopSubscribingToNotifications(characteristic) + .catchError((Object e) => + // ignore: avoid_print + print("Error unsubscribing from notifications: $e")), + ); + + isDisconnected.then((_) => autosubscribingRepeater.dispose()); + + return autosubscribingRepeater.stream; + } + @override Future requestMtu(String deviceId, int mtu) async => _blePlatform.requestMtuSize(deviceId, mtu); diff --git a/packages/flutter_reactive_ble/lib/src/device_connector.dart b/packages/flutter_reactive_ble/lib/src/device_connector.dart index 88e2a4fd..dab10f0e 100644 --- a/packages/flutter_reactive_ble/lib/src/device_connector.dart +++ b/packages/flutter_reactive_ble/lib/src/device_connector.dart @@ -19,6 +19,10 @@ abstract class DeviceConnector { Map>? servicesWithCharacteristicsToDiscover, Duration? connectionTimeout, }); + + Stream attachToConnectedDevice({ + required String id, + }); } class DeviceConnectorImpl implements DeviceConnector { @@ -104,6 +108,27 @@ class DeviceConnectorImpl implements DeviceConnector { } } + @override + Stream attachToConnectedDevice({ + required String id, + }) { + final specificConnectedDeviceStream = deviceConnectionStateUpdateStream + .where((update) => update.deviceId == id) + .expand((update) => + update.connectionState != DeviceConnectionState.disconnected + ? [update] + : [update, null]) + .takeWhile((update) => update != null) + .cast(); + + final autoconnectingRepeater = Repeater.broadcast( + onListenEmitFrom: () => specificConnectedDeviceStream, + onCancel: () => _blePlatform.disconnectDevice(id), + ); + + return autoconnectingRepeater.stream; + } + Stream _prescanAndConnect( String id, Map>? servicesWithCharacteristicsToDiscover, diff --git a/packages/flutter_reactive_ble/lib/src/reactive_ble.dart b/packages/flutter_reactive_ble/lib/src/reactive_ble.dart index cc1fd9bf..9f0a64c2 100644 --- a/packages/flutter_reactive_ble/lib/src/reactive_ble.dart +++ b/packages/flutter_reactive_ble/lib/src/reactive_ble.dart @@ -16,9 +16,15 @@ import 'package:reactive_ble_platform_interface/reactive_ble_platform_interface. /// perform all the supported BLE operations. class FlutterReactiveBle { static final FlutterReactiveBle _sharedInstance = FlutterReactiveBle._(); + static String? _restorationKey; factory FlutterReactiveBle() => _sharedInstance; + factory FlutterReactiveBle.withRestorationKey(String key) { + _restorationKey = key; + return _sharedInstance; + } + ///Create a new instance where injected dependencies are used. @visibleForTesting FlutterReactiveBle.witDependencies({ @@ -59,8 +65,16 @@ class FlutterReactiveBle { /// Also see [statusStream]. BleStatus get status => _status; + /// A stream providing bond updates for all the connected BLE devices. + Stream get bondUpdateStream => + Repeater.broadcast(onListenEmitFrom: () async* { + await initialize(); + yield* _blePlatform.bondUpdateStream; + }).stream; + /// A stream providing connection updates for all the connected BLE devices. - Stream get connectedDeviceStream => Repeater.broadcast(onListenEmitFrom: () async* { + Stream get connectedDeviceStream => + Repeater.broadcast(onListenEmitFrom: () async* { await initialize(); yield* _deviceConnector.deviceConnectionStateUpdateStream; }).stream; @@ -73,6 +87,25 @@ class FlutterReactiveBle { yield* _connectedDeviceOperator.characteristicValueStream; } + /// A stream providing devices restored from a previous instance. + Stream get restoredDeviceStream => + Repeater.broadcast(onListenEmitFrom: () async* { + await initialize(); + yield* _blePlatform.restoredDeviceStream.asyncMap( + (peripheral) async => RestoredDevice( + id: peripheral.id, + name: peripheral.name, + characteristicStreams: { + for (final char in peripheral.subscriptions) + char: (await resolveSingle(char)).attachToSubscription() + }, + connectionStream: _deviceConnector.attachToConnectedDevice( + id: peripheral.id, + ), + ), + ); + }).stream; + late ReactiveBlePlatform _blePlatform; BleStatus _status = BleStatus.unknown; @@ -104,9 +137,8 @@ class FlutterReactiveBle { ); if (Platform.isAndroid || Platform.isIOS) { - ReactiveBlePlatform.instance = const ReactiveBleMobilePlatformFactory().create( - logger: _debugLogger, - ); + ReactiveBlePlatform.instance = const ReactiveBleMobilePlatformFactory() + .create(logger: _debugLogger, restorationKey: _restorationKey); } _blePlatform = ReactiveBlePlatform.instance; @@ -160,7 +192,8 @@ class FlutterReactiveBle { /// This method assumes there is a single characteristic with the ids specified in [characteristic]. If there are /// multiple characteristics with the same id on a device, use [resolve] to find them all. Or use /// [getDiscoveredServices] to select the [Service]s and [Characteristic]s you're interested in. - Future> readCharacteristic(QualifiedCharacteristic characteristic) async { + Future> readCharacteristic( + QualifiedCharacteristic characteristic) async { await initialize(); return (await resolveSingle(characteristic)).read(); } @@ -177,7 +210,8 @@ class FlutterReactiveBle { required List value, }) async { await initialize(); - await (await resolveSingle(characteristic)).write(value, withResponse: true); + await (await resolveSingle(characteristic)) + .write(value, withResponse: true); } /// Writes a value to the specified characteristic without waiting for an acknowledgement. @@ -197,7 +231,8 @@ class FlutterReactiveBle { required List value, }) async { await initialize(); - await (await resolveSingle(characteristic)).write(value, withResponse: false); + await (await resolveSingle(characteristic)) + .write(value, withResponse: false); } /// Request a specific MTU for a connected device. @@ -216,10 +251,12 @@ class FlutterReactiveBle { /// Requests for a connection parameter update on the connected device. /// /// Always completes with an error on iOS, as there is no way (and no need) to perform this operation on iOS. - Future requestConnectionPriority({required String deviceId, required ConnectionPriority priority}) async { + Future requestConnectionPriority( + {required String deviceId, required ConnectionPriority priority}) async { await initialize(); - return _connectedDeviceOperator.requestConnectionPriority(deviceId, priority); + return _connectedDeviceOperator.requestConnectionPriority( + deviceId, priority); } /// Scan for BLE peripherals advertising the services specified in [withServices] @@ -267,7 +304,8 @@ class FlutterReactiveBle { initialize().asStream().asyncExpand( (_) => _deviceConnector.connect( id: id, - servicesWithCharacteristicsToDiscover: servicesWithCharacteristicsToDiscover, + servicesWithCharacteristicsToDiscover: + servicesWithCharacteristicsToDiscover, connectionTimeout: connectionTimeout, ), ); @@ -298,11 +336,18 @@ class FlutterReactiveBle { id: id, withServices: withServices, prescanDuration: prescanDuration, - servicesWithCharacteristicsToDiscover: servicesWithCharacteristicsToDiscover, + servicesWithCharacteristicsToDiscover: + servicesWithCharacteristicsToDiscover, connectionTimeout: connectionTimeout, ), ); + /// Disconnects a device with the provided id. + /// + /// Useful for restored devices where a connection subscription is not obtained. + Future disconnect({required String id}) => + _blePlatform.disconnectDevice(id); + /// Performs service discovery on the peripheral and returns the discovered services. /// /// When discovery fails this method throws an [Exception]. @@ -315,7 +360,8 @@ class FlutterReactiveBle { /// When discovery fails this method throws an [Exception]. /// /// Use [getDiscoveredServices] to get the discovered services - Future discoverAllServices(String deviceId) => _connectedDeviceOperator.discoverServices(deviceId); + Future discoverAllServices(String deviceId) => + _connectedDeviceOperator.discoverServices(deviceId); /// Services can be discovered by: /// - specify `servicesWithCharacteristicsToDiscover` in [connectToDevice] or [connectToAdvertisingDevice]. Or, @@ -327,13 +373,15 @@ class FlutterReactiveBle { /// Note: On Android, this method performs service discovery if one was done yet after connecting the device. Future> getDiscoveredServices(String deviceId) async { _disconnectionUpdates ??= connectedDeviceStream - .where((update) => update.connectionState == DeviceConnectionState.disconnected) + .where((update) => + update.connectionState == DeviceConnectionState.disconnected) .listen((update) { _services[update.deviceId]?.forEach((service) => service._markInvalid()); _services[update.deviceId]?.clear(); }); - final discoveredServices = await _connectedDeviceOperator.getDiscoverServices(deviceId); + final discoveredServices = + await _connectedDeviceOperator.getDiscoverServices(deviceId); final services = _services[deviceId] ?? []; @@ -351,27 +399,34 @@ class FlutterReactiveBle { }, ); - for (final discoveredCharacteristic in discoveredService.characteristics) { - if (!service._characteristics.any((char) => _isMatchingCharacteristic(char, discoveredCharacteristic))) { + for (final discoveredCharacteristic + in discoveredService.characteristics) { + if (!service._characteristics.any((char) => + _isMatchingCharacteristic(char, discoveredCharacteristic))) { service._characteristics.add(Characteristic._( id: discoveredCharacteristic.characteristicId, instanceId: discoveredCharacteristic.characteristicInstanceId, service: service, lib: this, isReadable: discoveredCharacteristic.isReadable, - isWritableWithoutResponse: discoveredCharacteristic.isWritableWithoutResponse, - isWritableWithResponse: discoveredCharacteristic.isWritableWithResponse, + isWritableWithoutResponse: + discoveredCharacteristic.isWritableWithoutResponse, + isWritableWithResponse: + discoveredCharacteristic.isWritableWithResponse, isNotifiable: discoveredCharacteristic.isNotifiable, isIndicatable: discoveredCharacteristic.isIndicatable, )); } } - service._characteristics.removeWhere((char) => !discoveredService.characteristics.any( - (discoveredCharacteristic) => _isMatchingCharacteristic(char, discoveredCharacteristic), - )); + service._characteristics + .removeWhere((char) => !discoveredService.characteristics.any( + (discoveredCharacteristic) => + _isMatchingCharacteristic(char, discoveredCharacteristic), + )); } services.removeWhere( - (service) => !discoveredServices.any((discoveredService) => _isMatchingService(service, discoveredService)), + (service) => !discoveredServices.any((discoveredService) => + _isMatchingService(service, discoveredService)), ); return UnmodifiableListView(services); @@ -379,10 +434,13 @@ class FlutterReactiveBle { StreamSubscription? _disconnectionUpdates; - bool _isMatchingService(Service service, DiscoveredService discoveredService) => - service.id == discoveredService.serviceId && service._instanceId == discoveredService.serviceInstanceId; + bool _isMatchingService( + Service service, DiscoveredService discoveredService) => + service.id == discoveredService.serviceId && + service._instanceId == discoveredService.serviceInstanceId; - bool _isMatchingCharacteristic(Characteristic char, DiscoveredCharacteristic discoveredCharacteristic) => + bool _isMatchingCharacteristic(Characteristic char, + DiscoveredCharacteristic discoveredCharacteristic) => char.id == discoveredCharacteristic.characteristicId && char._instanceId == discoveredCharacteristic.characteristicInstanceId; @@ -393,13 +451,15 @@ class FlutterReactiveBle { /// Always completes with an error on iOS, as there is no way (and no need) to perform this operation on iOS. /// /// The connection may need to be reestablished after successful GATT attribute cache clearing. - Future clearGattCache(String deviceId) => - _blePlatform.clearGattCache(deviceId).then((info) => info.dematerialize()); + Future clearGattCache(String deviceId) => _blePlatform + .clearGattCache(deviceId) + .then((info) => info.dematerialize()); /// Reads the RSSI of the of the peripheral with the given device ID. /// The peripheral must be connected, otherwise a [PlatformException] will be /// thrown - Future readRssi(String deviceId) async => _blePlatform.readRssi(deviceId); + Future readRssi(String deviceId) async => + _blePlatform.readRssi(deviceId); /// Subscribes to updates from the characteristic specified. /// @@ -408,24 +468,43 @@ class FlutterReactiveBle { /// This method assumes there is a single characteristic with the ids specified in [characteristic]. If there are /// multiple characteristics with the same id on a device, use [resolve] to find them all. Or use /// [getDiscoveredServices] to select the [Service]s and [Characteristic]s you're interested in. - Stream> subscribeToCharacteristic(QualifiedCharacteristic characteristic) async* { + Stream> subscribeToCharacteristic( + QualifiedCharacteristic characteristic) async* { yield* (await resolveSingle(characteristic)).subscribe(); } - Future> resolve(QualifiedCharacteristic characteristic) async { + Future> resolve( + QualifiedCharacteristic characteristic) async { final services = await getDiscoveredServices(characteristic.deviceId); - return services - .withId(characteristic.serviceId) - .expand((service) => service.characteristics.withId(characteristic.characteristicId)); + return services.withId(characteristic.serviceId).expand((service) => + service.characteristics.withId(characteristic.characteristicId)); } - Future resolveSingle(QualifiedCharacteristic characteristic) async { + Future resolveSingle( + QualifiedCharacteristic characteristic) async { final chars = await resolve(characteristic); - if (chars.isEmpty) throw Exception("Characteristic not found or discovered: $characteristic"); - if (chars.length > 1) throw Exception("Multiple matching characteristics found: $characteristic"); + if (chars.isEmpty) { + throw Exception( + "Characteristic not found or discovered: $characteristic"); + } + if (chars.length > 1) { + throw Exception( + "Multiple matching characteristics found: $characteristic"); + } return chars.single; } + /// Unsubscribes to updates from the characteristic specified. + /// + /// Useful for restored devices that do not read as "connected" + Future unsubscribeToCharacteristic( + QualifiedCharacteristic characteristic, + ) async { + await initialize(); + final instance = (await resolveSingle(characteristic))._ids; + return _blePlatform.stopSubscribingToNotifications(instance); + } + /// Sets the verbosity of debug output. /// /// Use [LogLevel.verbose] for full debug output. Make sure to run this only for debugging purposes. @@ -453,7 +532,8 @@ class Service { final String deviceId; /// Discovered characteristics - List get characteristics => UnmodifiableListView(_characteristics); + List get characteristics => + UnmodifiableListView(_characteristics); final List _characteristics = []; @@ -525,9 +605,11 @@ class Characteristic { _assertValidity(); if (withResponse) { - await _lib._connectedDeviceOperator.writeCharacteristicWithResponse(_ids, value: value); + await _lib._connectedDeviceOperator + .writeCharacteristicWithResponse(_ids, value: value); } else { - await _lib._connectedDeviceOperator.writeCharacteristicWithoutResponse(_ids, value: value); + await _lib._connectedDeviceOperator + .writeCharacteristicWithoutResponse(_ids, value: value); } } @@ -559,6 +641,35 @@ class Characteristic { ); } + /// Subscribes to updates from the characteristic specified. + /// + /// This stream terminates automatically when the device is disconnected. + Stream> attachToSubscription() { + _assertValidity(); + + final isDisconnected = _lib.connectedDeviceStream + .where((update) => + update.deviceId == service.deviceId && + (update.connectionState == DeviceConnectionState.disconnecting || + update.connectionState == DeviceConnectionState.disconnected)) + .cast() + .firstWhere((_) => true, orElse: () {}); + + return _lib.initialize().asStream().asyncExpand( + (_) => + _lib._connectedDeviceOperator.attachToCharacteristicSubscription( + CharacteristicInstance( + characteristicId: id, + characteristicInstanceId: _instanceId, + serviceId: service.id, + serviceInstanceId: service._instanceId, + deviceId: service.deviceId, + ), + isDisconnected, + ), + ); + } + // A Characteristic becomes invalid when its device gets disconnected. After reconnecting to the device, // services and characteristics have to be rediscovered bool _valid = true; @@ -587,13 +698,16 @@ class Characteristic { ); @override - String toString() => "Characteristic($id; $_instanceId; ${service._instanceId})"; + String toString() => + "Characteristic($id; $_instanceId; ${service._instanceId})"; } extension ServiceWithId on Iterable { - Iterable withId(Uuid id) => where((s) => s.id.expanded == id.expanded); + Iterable withId(Uuid id) => + where((s) => s.id.expanded == id.expanded); } extension CharacteristicWithId on Iterable { - Iterable withId(Uuid id) => where((c) => c.id.expanded == id.expanded); + Iterable withId(Uuid id) => + where((c) => c.id.expanded == id.expanded); } diff --git a/packages/flutter_reactive_ble/pubspec.lock b/packages/flutter_reactive_ble/pubspec.lock index 30dbafc6..2381f72f 100644 --- a/packages/flutter_reactive_ble/pubspec.lock +++ b/packages/flutter_reactive_ble/pubspec.lock @@ -295,26 +295,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" url: "https://pub.dev" source: hosted - version: "10.0.0" + version: "10.0.5" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.5" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.1" lints: dependency: transitive description: @@ -343,18 +343,18 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec url: "https://pub.dev" source: hosted - version: "0.8.0" + version: "0.11.1" meta: dependency: "direct main" description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.15.0" mime: dependency: transitive description: @@ -522,10 +522,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.2" timing: dependency: transitive description: @@ -554,10 +554,10 @@ packages: dependency: transitive description: name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "13.0.0" + version: "14.2.5" watcher: dependency: transitive description: @@ -592,4 +592,4 @@ packages: version: "3.1.2" sdks: dart: ">=3.3.0 <4.0.0" - flutter: ">=2.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/packages/flutter_reactive_ble/test/connected_device_operation_test.mocks.dart b/packages/flutter_reactive_ble/test/connected_device_operation_test.mocks.dart index fe85af06..417f482e 100644 --- a/packages/flutter_reactive_ble/test/connected_device_operation_test.mocks.dart +++ b/packages/flutter_reactive_ble/test/connected_device_operation_test.mocks.dart @@ -1,4 +1,4 @@ -// Mocks generated by Mockito 5.4.0 from annotations +// Mocks generated by Mockito 5.4.4 from annotations // in flutter_reactive_ble/test/connected_device_operation_test.dart. // Do not manually edit this file. @@ -14,6 +14,8 @@ import 'package:reactive_ble_platform_interface/src/reactive_ble_platform_interf // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors @@ -63,28 +65,45 @@ class MockReactiveBlePlatform extends _i1.Mock _i1.throwOnMissingStub(this); } + @override + _i4.Stream<_i2.BondStateUpdate> get bondUpdateStream => (super.noSuchMethod( + Invocation.getter(#bondUpdateStream), + returnValue: _i4.Stream<_i2.BondStateUpdate>.empty(), + ) as _i4.Stream<_i2.BondStateUpdate>); + @override _i4.Stream<_i2.ScanResult> get scanStream => (super.noSuchMethod( Invocation.getter(#scanStream), returnValue: _i4.Stream<_i2.ScanResult>.empty(), ) as _i4.Stream<_i2.ScanResult>); + @override _i4.Stream<_i2.BleStatus> get bleStatusStream => (super.noSuchMethod( Invocation.getter(#bleStatusStream), returnValue: _i4.Stream<_i2.BleStatus>.empty(), ) as _i4.Stream<_i2.BleStatus>); + @override _i4.Stream<_i2.ConnectionStateUpdate> get connectionUpdateStream => (super.noSuchMethod( Invocation.getter(#connectionUpdateStream), returnValue: _i4.Stream<_i2.ConnectionStateUpdate>.empty(), ) as _i4.Stream<_i2.ConnectionStateUpdate>); + + @override + _i4.Stream<_i2.RestoredPeripheral> get restoredDeviceStream => + (super.noSuchMethod( + Invocation.getter(#restoredDeviceStream), + returnValue: _i4.Stream<_i2.RestoredPeripheral>.empty(), + ) as _i4.Stream<_i2.RestoredPeripheral>); + @override _i4.Stream<_i2.CharacteristicValue> get charValueUpdateStream => (super.noSuchMethod( Invocation.getter(#charValueUpdateStream), returnValue: _i4.Stream<_i2.CharacteristicValue>.empty(), ) as _i4.Stream<_i2.CharacteristicValue>); + @override _i4.Future initialize() => (super.noSuchMethod( Invocation.method( @@ -94,6 +113,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override _i4.Future deinitialize() => (super.noSuchMethod( Invocation.method( @@ -103,6 +123,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override _i4.Stream scanForDevices({ required List<_i2.Uuid>? withServices, @@ -121,6 +142,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Stream.empty(), ) as _i4.Stream); + @override _i4.Future<_i2.Result<_i2.Unit, _i2.GenericFailure<_i2.ClearGattCacheError>?>> clearGattCache(String? deviceId) => (super.noSuchMethod( @@ -140,8 +162,9 @@ class MockReactiveBlePlatform extends _i1.Mock ), )), ) as _i4.Future< - _i2.Result<_i2.Unit, - _i2.GenericFailure<_i2.ClearGattCacheError>?>>); + _i2 + .Result<_i2.Unit, _i2.GenericFailure<_i2.ClearGattCacheError>?>>); + @override _i4.Future readRssi(String? deviceId) => (super.noSuchMethod( Invocation.method( @@ -150,6 +173,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Future.value(0), ) as _i4.Future); + @override _i4.Stream connectToDevice( String? id, @@ -167,6 +191,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Stream.empty(), ) as _i4.Stream); + @override _i4.Future disconnectDevice(String? deviceId) => (super.noSuchMethod( Invocation.method( @@ -176,6 +201,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override _i4.Future> discoverServices(String? deviceId) => (super.noSuchMethod( @@ -186,6 +212,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future>.value( <_i2.DiscoveredService>[]), ) as _i4.Future>); + @override _i4.Future> getDiscoverServices( String? deviceId) => @@ -197,6 +224,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future>.value( <_i2.DiscoveredService>[]), ) as _i4.Future>); + @override _i4.Stream readCharacteristic( _i2.CharacteristicInstance? characteristic) => @@ -207,6 +235,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Stream.empty(), ) as _i4.Stream); + @override _i4.Future<_i2.WriteCharacteristicInfo> writeCharacteristicWithResponse( _i2.CharacteristicInstance? characteristic, @@ -232,6 +261,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), )), ) as _i4.Future<_i2.WriteCharacteristicInfo>); + @override _i4.Future<_i2.WriteCharacteristicInfo> writeCharacteristicWithoutResponse( _i2.CharacteristicInstance? characteristic, @@ -257,6 +287,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), )), ) as _i4.Future<_i2.WriteCharacteristicInfo>); + @override _i4.Stream subscribeToNotifications( _i2.CharacteristicInstance? characteristic) => @@ -267,6 +298,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Stream.empty(), ) as _i4.Stream); + @override _i4.Future stopSubscribingToNotifications( _i2.CharacteristicInstance? characteristic) => @@ -278,6 +310,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override _i4.Future requestMtuSize( String? deviceId, @@ -293,6 +326,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Future.value(0), ) as _i4.Future); + @override _i4.Future<_i2.ConnectionPriorityInfo> requestConnectionPriority( String? deviceId, diff --git a/packages/flutter_reactive_ble/test/device_connector_test.mocks.dart b/packages/flutter_reactive_ble/test/device_connector_test.mocks.dart index 998f5d96..7ca7341f 100644 --- a/packages/flutter_reactive_ble/test/device_connector_test.mocks.dart +++ b/packages/flutter_reactive_ble/test/device_connector_test.mocks.dart @@ -1,4 +1,4 @@ -// Mocks generated by Mockito 5.4.0 from annotations +// Mocks generated by Mockito 5.4.4 from annotations // in flutter_reactive_ble/test/device_connector_test.dart. // Do not manually edit this file. @@ -16,6 +16,8 @@ import 'package:reactive_ble_platform_interface/src/models.dart' as _i2; // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors @@ -75,28 +77,45 @@ class MockReactiveBlePlatform extends _i1.Mock _i1.throwOnMissingStub(this); } + @override + _i4.Stream<_i2.BondStateUpdate> get bondUpdateStream => (super.noSuchMethod( + Invocation.getter(#bondUpdateStream), + returnValue: _i4.Stream<_i2.BondStateUpdate>.empty(), + ) as _i4.Stream<_i2.BondStateUpdate>); + @override _i4.Stream<_i2.ScanResult> get scanStream => (super.noSuchMethod( Invocation.getter(#scanStream), returnValue: _i4.Stream<_i2.ScanResult>.empty(), ) as _i4.Stream<_i2.ScanResult>); + @override _i4.Stream<_i2.BleStatus> get bleStatusStream => (super.noSuchMethod( Invocation.getter(#bleStatusStream), returnValue: _i4.Stream<_i2.BleStatus>.empty(), ) as _i4.Stream<_i2.BleStatus>); + @override _i4.Stream<_i2.ConnectionStateUpdate> get connectionUpdateStream => (super.noSuchMethod( Invocation.getter(#connectionUpdateStream), returnValue: _i4.Stream<_i2.ConnectionStateUpdate>.empty(), ) as _i4.Stream<_i2.ConnectionStateUpdate>); + + @override + _i4.Stream<_i2.RestoredPeripheral> get restoredDeviceStream => + (super.noSuchMethod( + Invocation.getter(#restoredDeviceStream), + returnValue: _i4.Stream<_i2.RestoredPeripheral>.empty(), + ) as _i4.Stream<_i2.RestoredPeripheral>); + @override _i4.Stream<_i2.CharacteristicValue> get charValueUpdateStream => (super.noSuchMethod( Invocation.getter(#charValueUpdateStream), returnValue: _i4.Stream<_i2.CharacteristicValue>.empty(), ) as _i4.Stream<_i2.CharacteristicValue>); + @override _i4.Future initialize() => (super.noSuchMethod( Invocation.method( @@ -106,6 +125,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override _i4.Future deinitialize() => (super.noSuchMethod( Invocation.method( @@ -115,6 +135,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override _i4.Stream scanForDevices({ required List<_i2.Uuid>? withServices, @@ -133,6 +154,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Stream.empty(), ) as _i4.Stream); + @override _i4.Future<_i2.Result<_i2.Unit, _i2.GenericFailure<_i2.ClearGattCacheError>?>> clearGattCache(String? deviceId) => (super.noSuchMethod( @@ -152,8 +174,9 @@ class MockReactiveBlePlatform extends _i1.Mock ), )), ) as _i4.Future< - _i2.Result<_i2.Unit, - _i2.GenericFailure<_i2.ClearGattCacheError>?>>); + _i2 + .Result<_i2.Unit, _i2.GenericFailure<_i2.ClearGattCacheError>?>>); + @override _i4.Future readRssi(String? deviceId) => (super.noSuchMethod( Invocation.method( @@ -162,6 +185,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Future.value(0), ) as _i4.Future); + @override _i4.Stream connectToDevice( String? id, @@ -179,6 +203,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Stream.empty(), ) as _i4.Stream); + @override _i4.Future disconnectDevice(String? deviceId) => (super.noSuchMethod( Invocation.method( @@ -188,6 +213,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override _i4.Future> discoverServices(String? deviceId) => (super.noSuchMethod( @@ -198,6 +224,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future>.value( <_i2.DiscoveredService>[]), ) as _i4.Future>); + @override _i4.Future> getDiscoverServices( String? deviceId) => @@ -209,6 +236,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future>.value( <_i2.DiscoveredService>[]), ) as _i4.Future>); + @override _i4.Stream readCharacteristic( _i2.CharacteristicInstance? characteristic) => @@ -219,6 +247,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Stream.empty(), ) as _i4.Stream); + @override _i4.Future<_i2.WriteCharacteristicInfo> writeCharacteristicWithResponse( _i2.CharacteristicInstance? characteristic, @@ -244,6 +273,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), )), ) as _i4.Future<_i2.WriteCharacteristicInfo>); + @override _i4.Future<_i2.WriteCharacteristicInfo> writeCharacteristicWithoutResponse( _i2.CharacteristicInstance? characteristic, @@ -269,6 +299,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), )), ) as _i4.Future<_i2.WriteCharacteristicInfo>); + @override _i4.Stream subscribeToNotifications( _i2.CharacteristicInstance? characteristic) => @@ -279,6 +310,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Stream.empty(), ) as _i4.Stream); + @override _i4.Future stopSubscribingToNotifications( _i2.CharacteristicInstance? characteristic) => @@ -290,6 +322,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override _i4.Future requestMtuSize( String? deviceId, @@ -305,6 +338,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Future.value(0), ) as _i4.Future); + @override _i4.Future<_i2.ConnectionPriorityInfo> requestConnectionPriority( String? deviceId, @@ -377,6 +411,7 @@ class MockDiscoveredDevicesRegistry extends _i1.Mock Invocation.getter(#getTimestamp), ), ) as DateTime Function()); + @override void add(String? deviceId) => super.noSuchMethod( Invocation.method( @@ -385,6 +420,7 @@ class MockDiscoveredDevicesRegistry extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void remove(String? deviceId) => super.noSuchMethod( Invocation.method( @@ -393,6 +429,7 @@ class MockDiscoveredDevicesRegistry extends _i1.Mock ), returnValueForMissingStub: null, ); + @override bool isEmpty() => (super.noSuchMethod( Invocation.method( @@ -401,6 +438,7 @@ class MockDiscoveredDevicesRegistry extends _i1.Mock ), returnValue: false, ) as bool); + @override bool deviceIsDiscoveredRecently({ required String? deviceId, diff --git a/packages/flutter_reactive_ble/test/device_scanner_test.mocks.dart b/packages/flutter_reactive_ble/test/device_scanner_test.mocks.dart index baee27ad..4201ce16 100644 --- a/packages/flutter_reactive_ble/test/device_scanner_test.mocks.dart +++ b/packages/flutter_reactive_ble/test/device_scanner_test.mocks.dart @@ -1,4 +1,4 @@ -// Mocks generated by Mockito 5.4.0 from annotations +// Mocks generated by Mockito 5.4.4 from annotations // in flutter_reactive_ble/test/device_scanner_test.dart. // Do not manually edit this file. @@ -14,6 +14,8 @@ import 'package:reactive_ble_platform_interface/src/reactive_ble_platform_interf // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors @@ -63,28 +65,45 @@ class MockReactiveBlePlatform extends _i1.Mock _i1.throwOnMissingStub(this); } + @override + _i4.Stream<_i2.BondStateUpdate> get bondUpdateStream => (super.noSuchMethod( + Invocation.getter(#bondUpdateStream), + returnValue: _i4.Stream<_i2.BondStateUpdate>.empty(), + ) as _i4.Stream<_i2.BondStateUpdate>); + @override _i4.Stream<_i2.ScanResult> get scanStream => (super.noSuchMethod( Invocation.getter(#scanStream), returnValue: _i4.Stream<_i2.ScanResult>.empty(), ) as _i4.Stream<_i2.ScanResult>); + @override _i4.Stream<_i2.BleStatus> get bleStatusStream => (super.noSuchMethod( Invocation.getter(#bleStatusStream), returnValue: _i4.Stream<_i2.BleStatus>.empty(), ) as _i4.Stream<_i2.BleStatus>); + @override _i4.Stream<_i2.ConnectionStateUpdate> get connectionUpdateStream => (super.noSuchMethod( Invocation.getter(#connectionUpdateStream), returnValue: _i4.Stream<_i2.ConnectionStateUpdate>.empty(), ) as _i4.Stream<_i2.ConnectionStateUpdate>); + + @override + _i4.Stream<_i2.RestoredPeripheral> get restoredDeviceStream => + (super.noSuchMethod( + Invocation.getter(#restoredDeviceStream), + returnValue: _i4.Stream<_i2.RestoredPeripheral>.empty(), + ) as _i4.Stream<_i2.RestoredPeripheral>); + @override _i4.Stream<_i2.CharacteristicValue> get charValueUpdateStream => (super.noSuchMethod( Invocation.getter(#charValueUpdateStream), returnValue: _i4.Stream<_i2.CharacteristicValue>.empty(), ) as _i4.Stream<_i2.CharacteristicValue>); + @override _i4.Future initialize() => (super.noSuchMethod( Invocation.method( @@ -94,6 +113,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override _i4.Future deinitialize() => (super.noSuchMethod( Invocation.method( @@ -103,6 +123,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override _i4.Stream scanForDevices({ required List<_i2.Uuid>? withServices, @@ -121,6 +142,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Stream.empty(), ) as _i4.Stream); + @override _i4.Future<_i2.Result<_i2.Unit, _i2.GenericFailure<_i2.ClearGattCacheError>?>> clearGattCache(String? deviceId) => (super.noSuchMethod( @@ -140,8 +162,9 @@ class MockReactiveBlePlatform extends _i1.Mock ), )), ) as _i4.Future< - _i2.Result<_i2.Unit, - _i2.GenericFailure<_i2.ClearGattCacheError>?>>); + _i2 + .Result<_i2.Unit, _i2.GenericFailure<_i2.ClearGattCacheError>?>>); + @override _i4.Future readRssi(String? deviceId) => (super.noSuchMethod( Invocation.method( @@ -150,6 +173,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Future.value(0), ) as _i4.Future); + @override _i4.Stream connectToDevice( String? id, @@ -167,6 +191,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Stream.empty(), ) as _i4.Stream); + @override _i4.Future disconnectDevice(String? deviceId) => (super.noSuchMethod( Invocation.method( @@ -176,6 +201,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override _i4.Future> discoverServices(String? deviceId) => (super.noSuchMethod( @@ -186,6 +212,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future>.value( <_i2.DiscoveredService>[]), ) as _i4.Future>); + @override _i4.Future> getDiscoverServices( String? deviceId) => @@ -197,6 +224,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future>.value( <_i2.DiscoveredService>[]), ) as _i4.Future>); + @override _i4.Stream readCharacteristic( _i2.CharacteristicInstance? characteristic) => @@ -207,6 +235,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Stream.empty(), ) as _i4.Stream); + @override _i4.Future<_i2.WriteCharacteristicInfo> writeCharacteristicWithResponse( _i2.CharacteristicInstance? characteristic, @@ -232,6 +261,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), )), ) as _i4.Future<_i2.WriteCharacteristicInfo>); + @override _i4.Future<_i2.WriteCharacteristicInfo> writeCharacteristicWithoutResponse( _i2.CharacteristicInstance? characteristic, @@ -257,6 +287,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), )), ) as _i4.Future<_i2.WriteCharacteristicInfo>); + @override _i4.Stream subscribeToNotifications( _i2.CharacteristicInstance? characteristic) => @@ -267,6 +298,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Stream.empty(), ) as _i4.Stream); + @override _i4.Future stopSubscribingToNotifications( _i2.CharacteristicInstance? characteristic) => @@ -278,6 +310,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override _i4.Future requestMtuSize( String? deviceId, @@ -293,6 +326,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Future.value(0), ) as _i4.Future); + @override _i4.Future<_i2.ConnectionPriorityInfo> requestConnectionPriority( String? deviceId, diff --git a/packages/flutter_reactive_ble/test/reactive_ble_test.mocks.dart b/packages/flutter_reactive_ble/test/reactive_ble_test.mocks.dart index 030c1276..dd4754eb 100644 --- a/packages/flutter_reactive_ble/test/reactive_ble_test.mocks.dart +++ b/packages/flutter_reactive_ble/test/reactive_ble_test.mocks.dart @@ -1,4 +1,4 @@ -// Mocks generated by Mockito 5.4.0 from annotations +// Mocks generated by Mockito 5.4.4 from annotations // in flutter_reactive_ble/test/reactive_ble_test.dart. // Do not manually edit this file. @@ -17,6 +17,8 @@ import 'package:reactive_ble_platform_interface/src/models.dart' as _i2; // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors @@ -66,28 +68,45 @@ class MockReactiveBlePlatform extends _i1.Mock _i1.throwOnMissingStub(this); } + @override + _i4.Stream<_i2.BondStateUpdate> get bondUpdateStream => (super.noSuchMethod( + Invocation.getter(#bondUpdateStream), + returnValue: _i4.Stream<_i2.BondStateUpdate>.empty(), + ) as _i4.Stream<_i2.BondStateUpdate>); + @override _i4.Stream<_i2.ScanResult> get scanStream => (super.noSuchMethod( Invocation.getter(#scanStream), returnValue: _i4.Stream<_i2.ScanResult>.empty(), ) as _i4.Stream<_i2.ScanResult>); + @override _i4.Stream<_i2.BleStatus> get bleStatusStream => (super.noSuchMethod( Invocation.getter(#bleStatusStream), returnValue: _i4.Stream<_i2.BleStatus>.empty(), ) as _i4.Stream<_i2.BleStatus>); + @override _i4.Stream<_i2.ConnectionStateUpdate> get connectionUpdateStream => (super.noSuchMethod( Invocation.getter(#connectionUpdateStream), returnValue: _i4.Stream<_i2.ConnectionStateUpdate>.empty(), ) as _i4.Stream<_i2.ConnectionStateUpdate>); + + @override + _i4.Stream<_i2.RestoredPeripheral> get restoredDeviceStream => + (super.noSuchMethod( + Invocation.getter(#restoredDeviceStream), + returnValue: _i4.Stream<_i2.RestoredPeripheral>.empty(), + ) as _i4.Stream<_i2.RestoredPeripheral>); + @override _i4.Stream<_i2.CharacteristicValue> get charValueUpdateStream => (super.noSuchMethod( Invocation.getter(#charValueUpdateStream), returnValue: _i4.Stream<_i2.CharacteristicValue>.empty(), ) as _i4.Stream<_i2.CharacteristicValue>); + @override _i4.Future initialize() => (super.noSuchMethod( Invocation.method( @@ -97,6 +116,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override _i4.Future deinitialize() => (super.noSuchMethod( Invocation.method( @@ -106,6 +126,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override _i4.Stream scanForDevices({ required List<_i2.Uuid>? withServices, @@ -124,6 +145,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Stream.empty(), ) as _i4.Stream); + @override _i4.Future<_i2.Result<_i2.Unit, _i2.GenericFailure<_i2.ClearGattCacheError>?>> clearGattCache(String? deviceId) => (super.noSuchMethod( @@ -143,8 +165,9 @@ class MockReactiveBlePlatform extends _i1.Mock ), )), ) as _i4.Future< - _i2.Result<_i2.Unit, - _i2.GenericFailure<_i2.ClearGattCacheError>?>>); + _i2 + .Result<_i2.Unit, _i2.GenericFailure<_i2.ClearGattCacheError>?>>); + @override _i4.Future readRssi(String? deviceId) => (super.noSuchMethod( Invocation.method( @@ -153,6 +176,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Future.value(0), ) as _i4.Future); + @override _i4.Stream connectToDevice( String? id, @@ -170,6 +194,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Stream.empty(), ) as _i4.Stream); + @override _i4.Future disconnectDevice(String? deviceId) => (super.noSuchMethod( Invocation.method( @@ -179,6 +204,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override _i4.Future> discoverServices(String? deviceId) => (super.noSuchMethod( @@ -189,6 +215,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future>.value( <_i2.DiscoveredService>[]), ) as _i4.Future>); + @override _i4.Future> getDiscoverServices( String? deviceId) => @@ -200,6 +227,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future>.value( <_i2.DiscoveredService>[]), ) as _i4.Future>); + @override _i4.Stream readCharacteristic( _i2.CharacteristicInstance? characteristic) => @@ -210,6 +238,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Stream.empty(), ) as _i4.Stream); + @override _i4.Future<_i2.WriteCharacteristicInfo> writeCharacteristicWithResponse( _i2.CharacteristicInstance? characteristic, @@ -235,6 +264,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), )), ) as _i4.Future<_i2.WriteCharacteristicInfo>); + @override _i4.Future<_i2.WriteCharacteristicInfo> writeCharacteristicWithoutResponse( _i2.CharacteristicInstance? characteristic, @@ -260,6 +290,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), )), ) as _i4.Future<_i2.WriteCharacteristicInfo>); + @override _i4.Stream subscribeToNotifications( _i2.CharacteristicInstance? characteristic) => @@ -270,6 +301,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Stream.empty(), ) as _i4.Stream); + @override _i4.Future stopSubscribingToNotifications( _i2.CharacteristicInstance? characteristic) => @@ -281,6 +313,7 @@ class MockReactiveBlePlatform extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override _i4.Future requestMtuSize( String? deviceId, @@ -296,6 +329,7 @@ class MockReactiveBlePlatform extends _i1.Mock ), returnValue: _i4.Future.value(0), ) as _i4.Future); + @override _i4.Future<_i2.ConnectionPriorityInfo> requestConnectionPriority( String? deviceId, @@ -339,11 +373,13 @@ class MockLogger extends _i1.Mock implements _i3.Logger { ), returnValueForMissingStub: null, ); + @override _i2.LogLevel get logLevel => (super.noSuchMethod( Invocation.getter(#logLevel), returnValue: _i2.LogLevel.none, ) as _i2.LogLevel); + @override void log(Object? message) => super.noSuchMethod( Invocation.method( @@ -369,6 +405,7 @@ class MockConnectedDeviceOperation extends _i1.Mock Invocation.getter(#characteristicValueStream), returnValue: _i4.Stream<_i2.CharacteristicValue>.empty(), ) as _i4.Stream<_i2.CharacteristicValue>); + @override _i4.Future> readCharacteristic( _i2.CharacteristicInstance? characteristic) => @@ -379,6 +416,7 @@ class MockConnectedDeviceOperation extends _i1.Mock ), returnValue: _i4.Future>.value([]), ) as _i4.Future>); + @override _i4.Future writeCharacteristicWithResponse( _i2.CharacteristicInstance? characteristic, { @@ -393,6 +431,7 @@ class MockConnectedDeviceOperation extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override _i4.Future writeCharacteristicWithoutResponse( _i2.CharacteristicInstance? characteristic, { @@ -407,6 +446,23 @@ class MockConnectedDeviceOperation extends _i1.Mock returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + + @override + _i4.Stream> attachToCharacteristicSubscription( + _i2.CharacteristicInstance? characteristic, + _i4.Future? isDisconnected, + ) => + (super.noSuchMethod( + Invocation.method( + #attachToCharacteristicSubscription, + [ + characteristic, + isDisconnected, + ], + ), + returnValue: _i4.Stream>.empty(), + ) as _i4.Stream>); + @override _i4.Stream> subscribeToCharacteristic( _i2.CharacteristicInstance? characteristic, @@ -422,6 +478,7 @@ class MockConnectedDeviceOperation extends _i1.Mock ), returnValue: _i4.Stream>.empty(), ) as _i4.Stream>); + @override _i4.Future requestMtu( String? deviceId, @@ -437,6 +494,7 @@ class MockConnectedDeviceOperation extends _i1.Mock ), returnValue: _i4.Future.value(0), ) as _i4.Future); + @override _i4.Future> discoverServices(String? deviceId) => (super.noSuchMethod( @@ -447,6 +505,7 @@ class MockConnectedDeviceOperation extends _i1.Mock returnValue: _i4.Future>.value( <_i2.DiscoveredService>[]), ) as _i4.Future>); + @override _i4.Future> getDiscoverServices( String? deviceId) => @@ -458,6 +517,7 @@ class MockConnectedDeviceOperation extends _i1.Mock returnValue: _i4.Future>.value( <_i2.DiscoveredService>[]), ) as _i4.Future>); + @override _i4.Future requestConnectionPriority( String? deviceId, @@ -490,6 +550,7 @@ class MockDeviceConnector extends _i1.Mock implements _i6.DeviceConnector { Invocation.getter(#deviceConnectionStateUpdateStream), returnValue: _i4.Stream<_i2.ConnectionStateUpdate>.empty(), ) as _i4.Stream<_i2.ConnectionStateUpdate>); + @override _i4.Stream<_i2.ConnectionStateUpdate> connect({ required String? id, @@ -509,6 +570,7 @@ class MockDeviceConnector extends _i1.Mock implements _i6.DeviceConnector { ), returnValue: _i4.Stream<_i2.ConnectionStateUpdate>.empty(), ) as _i4.Stream<_i2.ConnectionStateUpdate>); + @override _i4.Stream<_i2.ConnectionStateUpdate> connectToAdvertisingDevice({ required String? id, @@ -532,6 +594,18 @@ class MockDeviceConnector extends _i1.Mock implements _i6.DeviceConnector { ), returnValue: _i4.Stream<_i2.ConnectionStateUpdate>.empty(), ) as _i4.Stream<_i2.ConnectionStateUpdate>); + + @override + _i4.Stream<_i2.ConnectionStateUpdate> attachToConnectedDevice( + {required String? id}) => + (super.noSuchMethod( + Invocation.method( + #attachToConnectedDevice, + [], + {#id: id}, + ), + returnValue: _i4.Stream<_i2.ConnectionStateUpdate>.empty(), + ) as _i4.Stream<_i2.ConnectionStateUpdate>); } /// A class which mocks [DeviceScanner]. diff --git a/packages/reactive_ble_mobile/android/build.gradle b/packages/reactive_ble_mobile/android/build.gradle index e39fa4c3..0e1915d9 100644 --- a/packages/reactive_ble_mobile/android/build.gradle +++ b/packages/reactive_ble_mobile/android/build.gradle @@ -38,7 +38,7 @@ apply plugin: "io.gitlab.arturbosch.detekt" apply plugin: "de.mannodermaus.android-junit5" android { - compileSdkVersion 33 + compileSdkVersion 34 sourceSets { main.java.srcDirs += 'src/main/kotlin' test.java.srcDirs += 'src/test/kotlin' @@ -51,7 +51,7 @@ android { defaultConfig { minSdkVersion 21 - targetSdkVersion 33 + targetSdkVersion 34 consumerProguardFiles 'proguard-rules.txt' } diff --git a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/PluginController.kt b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/PluginController.kt index 22468cc2..e71e9750 100644 --- a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/PluginController.kt +++ b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/PluginController.kt @@ -4,8 +4,10 @@ import android.content.Context import com.signify.hue.flutterreactiveble.ble.RequestConnectionPriorityFailed import com.signify.hue.flutterreactiveble.channelhandlers.BleStatusHandler import com.signify.hue.flutterreactiveble.channelhandlers.CharNotificationHandler +import com.signify.hue.flutterreactiveble.channelhandlers.DeviceBondHandler import com.signify.hue.flutterreactiveble.channelhandlers.DeviceConnectionHandler import com.signify.hue.flutterreactiveble.channelhandlers.ScanDevicesHandler +import com.signify.hue.flutterreactiveble.channelhandlers.RestoredDeviceHandler import com.signify.hue.flutterreactiveble.converters.ProtobufMessageConverter import com.signify.hue.flutterreactiveble.converters.UuidConverter import com.signify.hue.flutterreactiveble.model.ClearGattCacheErrorType @@ -65,16 +67,22 @@ class PluginController { deviceConnectionChannel = EventChannel(messenger, "flutter_reactive_ble_connected_device") charNotificationChannel = EventChannel(messenger, "flutter_reactive_ble_char_update") val bleStatusChannel = EventChannel(messenger, "flutter_reactive_ble_status") + val bondUpdateChannel = EventChannel(messenger, "flutter_reactive_ble_bond_update") + val restoredDeviceChannel = EventChannel(messenger, "flutter_reactive_ble_restored_device") scanDevicesHandler = ScanDevicesHandler(bleClient) deviceConnectionHandler = DeviceConnectionHandler(bleClient) charNotificationHandler = CharNotificationHandler(bleClient) val bleStatusHandler = BleStatusHandler(bleClient) + val bondUpdateHandler = DeviceBondHandler(bleClient) + val restoredDeviceHandler = RestoredDeviceHandler() scanchannel.setStreamHandler(scanDevicesHandler) deviceConnectionChannel.setStreamHandler(deviceConnectionHandler) charNotificationChannel.setStreamHandler(charNotificationHandler) bleStatusChannel.setStreamHandler(bleStatusHandler) + bondUpdateChannel.setStreamHandler(bondUpdateHandler) + restoredDeviceChannel.setStreamHandler(restoredDeviceHandler) } internal fun deinitialize() { diff --git a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/BleClient.kt b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/BleClient.kt index 75870941..98943e3e 100644 --- a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/BleClient.kt +++ b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/BleClient.kt @@ -13,6 +13,7 @@ import java.util.UUID @Suppress("TooManyFunctions") interface BleClient { val connectionUpdateSubject: BehaviorSubject + val bondUpdateSubject: BehaviorSubject fun initializeClient() diff --git a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/BleWrapper.kt b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/BleWrapper.kt index d928f777..2d9ebc31 100644 --- a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/BleWrapper.kt +++ b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/BleWrapper.kt @@ -71,6 +71,11 @@ data class RequestConnectionPrioritySuccess(val deviceId: String) : RequestConne data class RequestConnectionPriorityFailed(val deviceId: String, val errorMessage: String) : RequestConnectionPriorityResult() +data class BondUpdate( + val deviceId: String, + val bondState: Int, +) + enum class BleStatus(val code: Int) { UNKNOWN(code = 0), UNSUPPORTED(code = 1), diff --git a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/ReactiveBleClient.kt b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/ReactiveBleClient.kt index 9fa076c1..d1126e88 100644 --- a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/ReactiveBleClient.kt +++ b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/ReactiveBleClient.kt @@ -1,8 +1,12 @@ package com.signify.hue.flutterreactiveble.ble +import android.bluetooth.BluetoothDevice import android.bluetooth.BluetoothDevice.BOND_BONDING import android.bluetooth.BluetoothGattCharacteristic +import android.content.BroadcastReceiver import android.content.Context +import android.content.Intent +import android.content.IntentFilter import android.os.Build import android.os.ParcelUuid import androidx.annotation.VisibleForTesting @@ -20,7 +24,9 @@ import com.signify.hue.flutterreactiveble.ble.extensions.resolveCharacteristic import com.signify.hue.flutterreactiveble.ble.extensions.writeCharWithResponse import com.signify.hue.flutterreactiveble.ble.extensions.writeCharWithoutResponse import com.signify.hue.flutterreactiveble.converters.extractManufacturerData +import com.signify.hue.flutterreactiveble.model.BondState import com.signify.hue.flutterreactiveble.model.ScanMode +import com.signify.hue.flutterreactiveble.model.getBondState import com.signify.hue.flutterreactiveble.model.toScanSettings import com.signify.hue.flutterreactiveble.utils.Duration import com.signify.hue.flutterreactiveble.utils.toBleState @@ -45,17 +51,29 @@ open class ReactiveBleClient(private val context: Context) : BleClient { private val connectionUpdateBehaviorSubject: BehaviorSubject = BehaviorSubject.create() + private val bondUpdateBehaviorSubject: BehaviorSubject = + BehaviorSubject.create() + lateinit var rxBleClient: RxBleClient internal set + internal var activeConnections = mutableMapOf() } override val connectionUpdateSubject: BehaviorSubject get() = connectionUpdateBehaviorSubject + override val bondUpdateSubject: BehaviorSubject + get() = bondUpdateBehaviorSubject + override fun initializeClient() { activeConnections = mutableMapOf() rxBleClient = RxBleClient.create(context) + + context.applicationContext.registerReceiver( + bondStateReceiver, + IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED), + ) } /*yes spread operator is not performant but after kotlin v1.60 it is less bad and it is also the @@ -276,7 +294,7 @@ open class ReactiveBleClient(private val context: Context) : BleClient { internal open fun createDeviceConnector( device: RxBleDevice, timeout: Duration, - ) = DeviceConnector(device, timeout, connectionUpdateBehaviorSubject::onNext, connectionQueue) + ) = DeviceConnector(device, timeout, ::onConnectionUpdate, connectionQueue) private fun getConnection( deviceId: String, @@ -404,4 +422,43 @@ open class ReactiveBleClient(private val context: Context) : BleClient { .setShouldLogAttributeValues(true) .build(), ) + + private fun onConnectionUpdate(update: ConnectionUpdate) { + when (update) { + is ConnectionUpdateSuccess -> { + val device = rxBleClient.getBleDevice(update.deviceId) + bondUpdateBehaviorSubject.onNext( + BondUpdate(update.deviceId, device.getBondState().code), + ) + } + + is ConnectionUpdateError -> { + val device = rxBleClient.getBleDevice(update.deviceId) + bondUpdateBehaviorSubject.onNext( + BondUpdate(update.deviceId, device.getBondState().code), + ) + } + } + + connectionUpdateBehaviorSubject.onNext(update) + } + + private val bondStateReceiver = + object : BroadcastReceiver() { + override fun onReceive( + context: Context, + intent: Intent, + ) { + val device = + intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE) + val state = + intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.ERROR) + + if (device != null && state != BluetoothDevice.ERROR) { + bondUpdateBehaviorSubject.onNext( + BondUpdate(device.address, BondState.fromRaw(state).code), + ) + } + } + } } diff --git a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/channelhandlers/DeviceBondHandler.kt b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/channelhandlers/DeviceBondHandler.kt new file mode 100644 index 00000000..554e118e --- /dev/null +++ b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/channelhandlers/DeviceBondHandler.kt @@ -0,0 +1,35 @@ +package com.signify.hue.flutterreactiveble.channelhandlers + +import com.signify.hue.flutterreactiveble.converters.ProtobufMessageConverter +import io.flutter.plugin.common.EventChannel +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.disposables.Disposable + +class DeviceBondHandler( + private val bleClient: com.signify.hue.flutterreactiveble.ble.BleClient, +) : EventChannel.StreamHandler { + private var sink: EventChannel.EventSink? = null + private val converter = ProtobufMessageConverter() + + private lateinit var disposable: Disposable + + override fun onListen( + objectSink: Any?, + eventSink: EventChannel.EventSink?, + ) { + eventSink?.let { + sink = eventSink + disposable = + bleClient.bondUpdateSubject + .distinct() + .observeOn(AndroidSchedulers.mainThread()) + .map(converter::convertToBondInfo) + .map { it.toByteArray() } + .subscribe { sink?.success(it) } + } + } + + override fun onCancel(objectSink: Any?) { + disposable.dispose() + } +} diff --git a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/channelhandlers/RestoredDeviceHandler.kt b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/channelhandlers/RestoredDeviceHandler.kt new file mode 100644 index 00000000..6da142d6 --- /dev/null +++ b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/channelhandlers/RestoredDeviceHandler.kt @@ -0,0 +1,24 @@ +package com.signify.hue.flutterreactiveble.channelhandlers + +import io.flutter.plugin.common.EventChannel +import com.signify.hue.flutterreactiveble.ProtobufModel as pb + +class RestoredDeviceHandler : EventChannel.StreamHandler { + private var sink: EventChannel.EventSink? = null + + override fun onListen( + objectSink: Any?, + eventSink: EventChannel.EventSink?, + ) { + eventSink?.let { + sink = eventSink + + val message = pb.RestoredDeviceInfoCollection.newBuilder().build() + eventSink.success(message.toByteArray()) + } + } + + override fun onCancel(objectSink: Any?) { + sink = null + } +} diff --git a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/converters/ProtobufMessageConverter.kt b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/converters/ProtobufMessageConverter.kt index 7c8077f0..51ea1a25 100644 --- a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/converters/ProtobufMessageConverter.kt +++ b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/converters/ProtobufMessageConverter.kt @@ -4,6 +4,7 @@ import android.bluetooth.BluetoothGattCharacteristic import android.bluetooth.BluetoothGattService import com.google.protobuf.ByteString import com.polidea.rxandroidble2.RxBleDeviceServices +import com.signify.hue.flutterreactiveble.ble.BondUpdate import com.signify.hue.flutterreactiveble.ble.ConnectionUpdateSuccess import com.signify.hue.flutterreactiveble.ble.MtuNegotiateFailed import com.signify.hue.flutterreactiveble.ble.MtuNegotiateResult @@ -55,6 +56,13 @@ class ProtobufMessageConverter { ) .build() + fun convertToBondInfo(update: BondUpdate): pb.BondInfo = + pb.BondInfo + .newBuilder() + .setId(update.deviceId) + .setBondState(update.bondState) + .build() + fun convertToDeviceInfo(connection: ConnectionUpdateSuccess): pb.DeviceInfo = pb.DeviceInfo.newBuilder() .setId(connection.deviceId) diff --git a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/model/BondState.kt b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/model/BondState.kt new file mode 100644 index 00000000..64f53377 --- /dev/null +++ b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/model/BondState.kt @@ -0,0 +1,24 @@ +package com.signify.hue.flutterreactiveble.model + +import android.bluetooth.BluetoothDevice +import com.polidea.rxandroidble2.RxBleDevice + +enum class BondState( + val code: Int, +) { + NONE(0), + BONDING(1), + BONDED(2), + ; + + companion object { + fun fromRaw(raw: Int): BondState = + when (raw) { + BluetoothDevice.BOND_BONDING -> BONDING + BluetoothDevice.BOND_BONDED -> BONDED + else -> NONE + } + } +} + +fun RxBleDevice.getBondState(): BondState = BondState.fromRaw(bluetoothDevice.bondState) diff --git a/packages/reactive_ble_mobile/example/android/gradle/wrapper/gradle-wrapper.jar b/packages/reactive_ble_mobile/example/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..13372aef Binary files /dev/null and b/packages/reactive_ble_mobile/example/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/packages/reactive_ble_mobile/example/android/gradlew b/packages/reactive_ble_mobile/example/android/gradlew new file mode 100755 index 00000000..9d82f789 --- /dev/null +++ b/packages/reactive_ble_mobile/example/android/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/packages/reactive_ble_mobile/example/android/gradlew.bat b/packages/reactive_ble_mobile/example/android/gradlew.bat new file mode 100644 index 00000000..aec99730 --- /dev/null +++ b/packages/reactive_ble_mobile/example/android/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/packages/reactive_ble_mobile/ios/Classes/BleData extras/RestoredPeripheral.swift b/packages/reactive_ble_mobile/ios/Classes/BleData extras/RestoredPeripheral.swift new file mode 100644 index 00000000..018ba1b7 --- /dev/null +++ b/packages/reactive_ble_mobile/ios/Classes/BleData extras/RestoredPeripheral.swift @@ -0,0 +1,58 @@ +import CoreBluetooth.CBPeripheral + +struct RestoredPeripheral: Equatable { + let identifier: PeripheralID + let name: String + let subscriptions: [CharacteristicAddress] + let status: RestorationStatus +} + +extension RestoredPeripheral { + + init(_ peripheral: CBPeripheral) { + var status: RestorationStatus = .restored + if let services = peripheral.services, !services.isEmpty { + for service in services { + if service.characteristics == nil || service.characteristics!.isEmpty { + status = .pendingDiscovery + break + } + } + } else { + status = .pendingDiscovery + } + + var subscriptions: [CharacteristicAddress]? + if status == .restored, let services = peripheral.services { + subscriptions = services.reduce([CharacteristicAddress](), { partialResult, service in + guard let characteristics = service.characteristics + else { return partialResult } + + let notifying: [CharacteristicAddress] = characteristics.compactMap({ characteristic in + guard characteristic.isNotifying + else { return nil } + + return CharacteristicAddress.with { + $0.deviceID = peripheral.identifier.uuidString + $0.serviceUuid = Uuid.with { $0.data = service.uuid.data} + $0.characteristicUuid = Uuid.with { $0.data = characteristic.uuid.data } + } + }) + + return partialResult + notifying + }) + } + + self.init( + identifier: peripheral.identifier, + name: peripheral.name ?? "", + subscriptions: subscriptions ?? [CharacteristicAddress](), + status: status + ) + } +} + +enum RestorationStatus { + case pendingDiscovery + case restored +} diff --git a/packages/reactive_ble_mobile/ios/Classes/BleData/bledata.pb.swift b/packages/reactive_ble_mobile/ios/Classes/BleData/bledata.pb.swift index bbc4e9b3..852fc85b 100644 --- a/packages/reactive_ble_mobile/ios/Classes/BleData/bledata.pb.swift +++ b/packages/reactive_ble_mobile/ios/Classes/BleData/bledata.pb.swift @@ -1,5 +1,6 @@ // DO NOT EDIT. // swift-format-ignore-file +// swiftlint:disable all // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: bledata.proto @@ -20,7 +21,19 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP typealias Version = _2 } -struct ScanForDevicesRequest { +struct InitializationRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var restorationKey: String = String() + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct ScanForDevicesRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -36,7 +49,7 @@ struct ScanForDevicesRequest { init() {} } -struct DeviceScanInfo { +struct DeviceScanInfo: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -79,7 +92,7 @@ struct DeviceScanInfo { fileprivate var _isConnectable: IsConnectable? = nil } -struct ConnectToDeviceRequest { +struct ConnectToDeviceRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -104,7 +117,21 @@ struct ConnectToDeviceRequest { fileprivate var _servicesWithCharacteristicsToDiscover: ServicesWithCharacteristics? = nil } -struct DeviceInfo { +struct BondInfo: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var id: String = String() + + var bondState: Int32 = 0 + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct DeviceInfo: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -129,7 +156,35 @@ struct DeviceInfo { fileprivate var _failure: GenericFailure? = nil } -struct DisconnectFromDeviceRequest { +struct RestoredDeviceInfo: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var id: String = String() + + var name: String = String() + + var subscriptions: [CharacteristicAddress] = [] + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct RestoredDeviceInfoCollection: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var devices: [RestoredDeviceInfo] = [] + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct DisconnectFromDeviceRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -141,7 +196,7 @@ struct DisconnectFromDeviceRequest { init() {} } -struct ClearGattCacheRequest { +struct ClearGattCacheRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -153,7 +208,7 @@ struct ClearGattCacheRequest { init() {} } -struct ClearGattCacheInfo { +struct ClearGattCacheInfo: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -174,7 +229,7 @@ struct ClearGattCacheInfo { fileprivate var _failure: GenericFailure? = nil } -struct NotifyCharacteristicRequest { +struct NotifyCharacteristicRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -195,7 +250,7 @@ struct NotifyCharacteristicRequest { fileprivate var _characteristic: CharacteristicAddress? = nil } -struct NotifyNoMoreCharacteristicRequest { +struct NotifyNoMoreCharacteristicRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -216,7 +271,7 @@ struct NotifyNoMoreCharacteristicRequest { fileprivate var _characteristic: CharacteristicAddress? = nil } -struct ReadCharacteristicRequest { +struct ReadCharacteristicRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -237,7 +292,7 @@ struct ReadCharacteristicRequest { fileprivate var _characteristic: CharacteristicAddress? = nil } -struct CharacteristicValueInfo { +struct CharacteristicValueInfo: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -270,7 +325,7 @@ struct CharacteristicValueInfo { fileprivate var _failure: GenericFailure? = nil } -struct WriteCharacteristicRequest { +struct WriteCharacteristicRequest: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -293,7 +348,7 @@ struct WriteCharacteristicRequest { fileprivate var _characteristic: CharacteristicAddress? = nil } -struct WriteCharacteristicInfo { +struct WriteCharacteristicInfo: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -324,7 +379,7 @@ struct WriteCharacteristicInfo { fileprivate var _failure: GenericFailure? = nil } -struct NegotiateMtuRequest { +struct NegotiateMtuRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -338,7 +393,7 @@ struct NegotiateMtuRequest { init() {} } -struct NegotiateMtuInfo { +struct NegotiateMtuInfo: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -363,7 +418,7 @@ struct NegotiateMtuInfo { fileprivate var _failure: GenericFailure? = nil } -struct BleStatusInfo { +struct BleStatusInfo: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -375,7 +430,7 @@ struct BleStatusInfo { init() {} } -struct ChangeConnectionPriorityRequest { +struct ChangeConnectionPriorityRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -389,7 +444,7 @@ struct ChangeConnectionPriorityRequest { init() {} } -struct ChangeConnectionPriorityInfo { +struct ChangeConnectionPriorityInfo: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -412,7 +467,7 @@ struct ChangeConnectionPriorityInfo { fileprivate var _failure: GenericFailure? = nil } -struct CharacteristicAddress { +struct CharacteristicAddress: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -449,7 +504,7 @@ struct CharacteristicAddress { fileprivate var _characteristicUuid: Uuid? = nil } -struct ServiceDataEntry { +struct ServiceDataEntry: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -472,7 +527,7 @@ struct ServiceDataEntry { fileprivate var _serviceUuid: Uuid? = nil } -struct ServicesWithCharacteristics { +struct ServicesWithCharacteristics: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -484,7 +539,7 @@ struct ServicesWithCharacteristics { init() {} } -struct ServiceWithCharacteristics { +struct ServiceWithCharacteristics: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -507,7 +562,7 @@ struct ServiceWithCharacteristics { fileprivate var _serviceID: Uuid? = nil } -struct DiscoverServicesRequest { +struct DiscoverServicesRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -519,7 +574,7 @@ struct DiscoverServicesRequest { init() {} } -struct DiscoverServicesInfo { +struct DiscoverServicesInfo: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -533,7 +588,7 @@ struct DiscoverServicesInfo { init() {} } -struct DiscoveredService { +struct DiscoveredService: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -562,7 +617,7 @@ struct DiscoveredService { fileprivate var _serviceUuid: Uuid? = nil } -struct DiscoveredCharacteristic { +struct DiscoveredCharacteristic: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -605,7 +660,7 @@ struct DiscoveredCharacteristic { fileprivate var _serviceID: Uuid? = nil } -struct ReadRssiRequest { +struct ReadRssiRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -617,7 +672,7 @@ struct ReadRssiRequest { init() {} } -struct ReadRssiResult { +struct ReadRssiResult: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -629,7 +684,19 @@ struct ReadRssiResult { init() {} } -struct Uuid { +struct DeviceInfoCollection: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var devices: [DeviceInfo] = [] + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct Uuid: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -641,7 +708,7 @@ struct Uuid { init() {} } -struct GenericFailure { +struct GenericFailure: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -655,7 +722,7 @@ struct GenericFailure { init() {} } -struct IsConnectable { +struct IsConnectable: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. @@ -667,42 +734,40 @@ struct IsConnectable { init() {} } -#if swift(>=5.5) && canImport(_Concurrency) -extension ScanForDevicesRequest: @unchecked Sendable {} -extension DeviceScanInfo: @unchecked Sendable {} -extension ConnectToDeviceRequest: @unchecked Sendable {} -extension DeviceInfo: @unchecked Sendable {} -extension DisconnectFromDeviceRequest: @unchecked Sendable {} -extension ClearGattCacheRequest: @unchecked Sendable {} -extension ClearGattCacheInfo: @unchecked Sendable {} -extension NotifyCharacteristicRequest: @unchecked Sendable {} -extension NotifyNoMoreCharacteristicRequest: @unchecked Sendable {} -extension ReadCharacteristicRequest: @unchecked Sendable {} -extension CharacteristicValueInfo: @unchecked Sendable {} -extension WriteCharacteristicRequest: @unchecked Sendable {} -extension WriteCharacteristicInfo: @unchecked Sendable {} -extension NegotiateMtuRequest: @unchecked Sendable {} -extension NegotiateMtuInfo: @unchecked Sendable {} -extension BleStatusInfo: @unchecked Sendable {} -extension ChangeConnectionPriorityRequest: @unchecked Sendable {} -extension ChangeConnectionPriorityInfo: @unchecked Sendable {} -extension CharacteristicAddress: @unchecked Sendable {} -extension ServiceDataEntry: @unchecked Sendable {} -extension ServicesWithCharacteristics: @unchecked Sendable {} -extension ServiceWithCharacteristics: @unchecked Sendable {} -extension DiscoverServicesRequest: @unchecked Sendable {} -extension DiscoverServicesInfo: @unchecked Sendable {} -extension DiscoveredService: @unchecked Sendable {} -extension DiscoveredCharacteristic: @unchecked Sendable {} -extension ReadRssiRequest: @unchecked Sendable {} -extension ReadRssiResult: @unchecked Sendable {} -extension Uuid: @unchecked Sendable {} -extension GenericFailure: @unchecked Sendable {} -extension IsConnectable: @unchecked Sendable {} -#endif // swift(>=5.5) && canImport(_Concurrency) - // MARK: - Code below here is support for the SwiftProtobuf runtime. +extension InitializationRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "InitializationRequest" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "restorationKey"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.restorationKey) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.restorationKey.isEmpty { + try visitor.visitSingularStringField(value: self.restorationKey, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: InitializationRequest, rhs: InitializationRequest) -> Bool { + if lhs.restorationKey != rhs.restorationKey {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + extension ScanForDevicesRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = "ScanForDevicesRequest" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ @@ -873,6 +938,44 @@ extension ConnectToDeviceRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageI } } +extension BondInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "BondInfo" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + 2: .same(proto: "bondState"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.id) }() + case 2: try { try decoder.decodeSingularInt32Field(value: &self.bondState) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.id.isEmpty { + try visitor.visitSingularStringField(value: self.id, fieldNumber: 1) + } + if self.bondState != 0 { + try visitor.visitSingularInt32Field(value: self.bondState, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: BondInfo, rhs: BondInfo) -> Bool { + if lhs.id != rhs.id {return false} + if lhs.bondState != rhs.bondState {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + extension DeviceInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = "DeviceInfo" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ @@ -921,6 +1024,82 @@ extension DeviceInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementatio } } +extension RestoredDeviceInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RestoredDeviceInfo" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + 2: .same(proto: "name"), + 3: .same(proto: "subscriptions"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.id) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.name) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.subscriptions) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.id.isEmpty { + try visitor.visitSingularStringField(value: self.id, fieldNumber: 1) + } + if !self.name.isEmpty { + try visitor.visitSingularStringField(value: self.name, fieldNumber: 2) + } + if !self.subscriptions.isEmpty { + try visitor.visitRepeatedMessageField(value: self.subscriptions, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RestoredDeviceInfo, rhs: RestoredDeviceInfo) -> Bool { + if lhs.id != rhs.id {return false} + if lhs.name != rhs.name {return false} + if lhs.subscriptions != rhs.subscriptions {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension RestoredDeviceInfoCollection: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "RestoredDeviceInfoCollection" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "devices"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.devices) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.devices.isEmpty { + try visitor.visitRepeatedMessageField(value: self.devices, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: RestoredDeviceInfoCollection, rhs: RestoredDeviceInfoCollection) -> Bool { + if lhs.devices != rhs.devices {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + extension DisconnectFromDeviceRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = "DisconnectFromDeviceRequest" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ @@ -1907,6 +2086,38 @@ extension ReadRssiResult: SwiftProtobuf.Message, SwiftProtobuf._MessageImplement } } +extension DeviceInfoCollection: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = "DeviceInfoCollection" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "devices"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.devices) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.devices.isEmpty { + try visitor.visitRepeatedMessageField(value: self.devices, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: DeviceInfoCollection, rhs: DeviceInfoCollection) -> Bool { + if lhs.devices != rhs.devices {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + extension Uuid: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = "Uuid" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ diff --git a/packages/reactive_ble_mobile/ios/Classes/Plugin/PluginController.swift b/packages/reactive_ble_mobile/ios/Classes/Plugin/PluginController.swift index 6190cacc..6c2b5362 100644 --- a/packages/reactive_ble_mobile/ios/Classes/Plugin/PluginController.swift +++ b/packages/reactive_ble_mobile/ios/Classes/Plugin/PluginController.swift @@ -23,10 +23,12 @@ final class PluginController { } } var messageQueue: [CharacteristicValueInfo] = [] + var restoredDeviceQueue: [RestoredDeviceInfo] = [] var connectedDeviceSink: EventSink? + var restoredDeviceSink: EventSink? var characteristicValueUpdateSink: EventSink? - func initialize(name: String, completion: @escaping PlatformMethodCompletionHandler) { + func initialize(name: String, args: InitializationRequest, completion: @escaping PlatformMethodCompletionHandler) { if let central = central { central.stopScan() central.disconnectAll() @@ -71,6 +73,7 @@ final class PluginController { }, onConnectionChange: papply(weak: self) { context, central, peripheral, change in let failure: (code: ConnectionFailure, message: String)? + let message: DeviceInfo? switch change { case .connected: @@ -78,19 +81,20 @@ final class PluginController { return case .failedToConnect(let underlyingError), .disconnected(let underlyingError): failure = underlyingError.map { (.failedToConnect, "\($0)") } - } - - let message = DeviceInfo.with { - $0.id = peripheral.identifier.uuidString - $0.connectionState = encode(peripheral.state) - if let error = failure { - $0.failure = GenericFailure.with { - $0.code = Int32(error.code.rawValue) - $0.message = error.message + message = DeviceInfo.with { + $0.id = peripheral.identifier.uuidString + $0.connectionState = encode(peripheral.state) + if let error = failure { + $0.failure = GenericFailure.with { + $0.code = Int32(error.code.rawValue) + $0.message = error.message + } } } } + + context.connectedDeviceSink?.add(.success(message)) }, onServicesWithCharacteristicsInitialDiscovery: papply(weak: self) { context, central, peripheral, errors in @@ -136,7 +140,26 @@ final class PluginController { // In case message arrives before sink is created context.messageQueue.append(message) } - } + + }, + onPeripheralsRestored: papply(weak: self) { (context, central, peripherals) -> Void in + let message = RestoredDeviceInfoCollection.with { + $0.devices = peripherals.map({ peripheral in + RestoredDeviceInfo.with { + $0.id = peripheral.identifier.uuidString + $0.name = peripheral.name + $0.subscriptions = peripheral.subscriptions + } + }) + } + + if let sink = context.restoredDeviceSink { + sink.add(.success(message)) + } else { + context.restoredDeviceQueue.append(contentsOf: message.devices) + } + }, + restorationKey: args.restorationKey ) completion(.success(nil)) @@ -429,6 +452,8 @@ final class PluginController { completion(.success(nil)) } }) + } catch Central.Failure.peripheralIsUnknown { + completion(.success(nil)) } catch { completion(.failure(PluginError.unknown(error).asFlutterError)) } diff --git a/packages/reactive_ble_mobile/ios/Classes/Plugin/SwiftReactiveBlePlugin.swift b/packages/reactive_ble_mobile/ios/Classes/Plugin/SwiftReactiveBlePlugin.swift index 15bf162f..057ae864 100644 --- a/packages/reactive_ble_mobile/ios/Classes/Plugin/SwiftReactiveBlePlugin.swift +++ b/packages/reactive_ble_mobile/ios/Classes/Plugin/SwiftReactiveBlePlugin.swift @@ -16,6 +16,23 @@ public class SwiftReactiveBlePlugin: NSObject, FlutterPlugin { .setStreamHandler(plugin.connectedDeviceStreamHandler) FlutterEventChannel(name: "flutter_reactive_ble_char_update", binaryMessenger: registrar.messenger()) .setStreamHandler(plugin.characteristicValueUpdateStreamHandler) + FlutterEventChannel(name: "flutter_reactive_ble_restored_device", binaryMessenger: registrar.messenger()) + .setStreamHandler(plugin.restoredDeviceStreamHandler) + FlutterEventChannel(name: "flutter_reactive_ble_bond_update", binaryMessenger: registrar.messenger()) + .setStreamHandler(plugin.bondUpdateStreamHandler) + } + + var bondUpdateStreamHandler: StreamHandler { + return StreamHandler( + name: "bond update stream handler", + context: context, + onListen: { context, sink in + return nil + }, + onCancel: { context in + return nil + } + ) } var statusStreamHandler: StreamHandler { @@ -60,6 +77,31 @@ public class SwiftReactiveBlePlugin: NSObject, FlutterPlugin { } ) } + + var restoredDeviceStreamHandler: StreamHandler { + return StreamHandler( + name: "restored device stream handler", + context: context, + onListen: { context, sink in + context.restoredDeviceSink = sink + var messages = [RestoredDeviceInfo]() + context.restoredDeviceQueue.forEach { msg in + messages.append(msg) + } + context.restoredDeviceQueue.removeAll() + let message = RestoredDeviceInfoCollection.with { + $0.devices = messages + } + sink.add(.success(message)) + return nil + }, + onCancel: { context in + context.restoredDeviceQueue.removeAll() + context.restoredDeviceSink = nil + return nil + } + ) + } var characteristicValueUpdateStreamHandler: StreamHandler { return StreamHandler( @@ -84,8 +126,8 @@ public class SwiftReactiveBlePlugin: NSObject, FlutterPlugin { private let context = PluginController() private let methodHandler = MethodHandler([ - AnyPlatformMethod(NullaryPlatformMethod(name: "initialize") { name, context, completion in - context.initialize(name: name, completion: completion) + AnyPlatformMethod(UnaryPlatformMethod (name: "initialize") { (name, context, args: InitializationRequest, completion) in + context.initialize(name: name, args: args, completion: completion) }), AnyPlatformMethod(NullaryPlatformMethod(name: "deinitialize") { name, context, completion in context.deinitialize(name: name, completion: completion) diff --git a/packages/reactive_ble_mobile/ios/Classes/ReactiveBle/Central.swift b/packages/reactive_ble_mobile/ios/Classes/ReactiveBle/Central.swift index 60e5f34a..d3cc3221 100644 --- a/packages/reactive_ble_mobile/ios/Classes/ReactiveBle/Central.swift +++ b/packages/reactive_ble_mobile/ios/Classes/ReactiveBle/Central.swift @@ -20,15 +20,18 @@ final class Central { typealias CharacteristicNotifyCompletionHandler = (Central, Error?) -> Void typealias CharacteristicValueUpdateHandler = (Central, CharacteristicInstance, Data?, Error?) -> Void typealias CharacteristicWriteCompletionHandler = (Central, CharacteristicInstance, Error?) -> Void + typealias PeripheralsRestoredHandler = (Central, [RestoredPeripheral]) -> Void private let onServicesWithCharacteristicsInitialDiscovery: ServicesWithCharacteristicsDiscoveryHandler private var peripheralDelegate: PeripheralDelegate! private var centralManagerDelegate: CentralManagerDelegate! private var centralManager: CBCentralManager! + private var restorationKey: String? private(set) var isScanning = false private(set) var activePeripherals = [PeripheralID: CBPeripheral]() + private(set) var restoredPeripherals = [PeripheralID: RestoredPeripheral]() private(set) var connectRegistry = PeripheralTaskRegistry() private let servicesWithCharacteristicsDiscoveryRegistry = PeripheralTaskRegistry() private let characteristicNotifyRegistry = PeripheralTaskRegistry() @@ -40,7 +43,9 @@ final class Central { onDiscovery: @escaping DiscoveryHandler, onConnectionChange: @escaping ConnectionChangeHandler, onServicesWithCharacteristicsInitialDiscovery: @escaping ServicesWithCharacteristicsDiscoveryHandler, - onCharacteristicValueUpdate: @escaping CharacteristicValueUpdateHandler + onCharacteristicValueUpdate: @escaping CharacteristicValueUpdateHandler, + onPeripheralsRestored: @escaping PeripheralsRestoredHandler, + restorationKey: String? ) { self.onServicesWithCharacteristicsInitialDiscovery = onServicesWithCharacteristicsInitialDiscovery self.centralManagerDelegate = CentralManagerDelegate( @@ -55,7 +60,7 @@ final class Central { onStateChange(central, state) }, onDiscovery: papply(weak: self, onDiscovery), - onConnectionChange: papply(weak: self) { central, peripheral, change in + onConnectionChange: papply(weak: self) { (central: Central, peripheral: CBPeripheral, change:ConnectionChange) -> Void in central.connectRegistry.updateTask( key: peripheral.identifier, action: { $0.handleConnectionChange(change) } @@ -69,6 +74,37 @@ final class Central { } onConnectionChange(central, peripheral, change) + }, + onPeripheralsRestored: papply(weak: self) { (central: Central, peripherals: [CBPeripheral]) -> Void in + peripherals.forEach { + $0.delegate = self.peripheralDelegate + central.activePeripherals[$0.identifier] = $0 + + let peripheral = RestoredPeripheral($0) + central.restoredPeripherals[peripheral.identifier] = peripheral + + if peripheral.status == .pendingDiscovery { + do { + try central.discoverServicesWithCharacteristics( + for: peripheral.identifier, + discover: .all, + completion: { central, peripheral, errors in + central.restoredPeripherals[peripheral.identifier] = RestoredPeripheral(peripheral) + + if (!central.hasRestoredPeripheralsPendingDiscovery()) { + onPeripheralsRestored(central, Array(central.restoredPeripherals.values)) + } + } + ) + } catch { + print("Error restoring services or characteristics for peripheral. ID: \(peripheral.identifier) Error: \(error)") + } + } + } + + if (!central.hasRestoredPeripheralsPendingDiscovery()) { + onPeripheralsRestored(central, Array(central.restoredPeripherals.values)) + } } ) self.peripheralDelegate = PeripheralDelegate( @@ -121,9 +157,11 @@ final class Central { ) } ) + self.restorationKey = restorationKey self.centralManager = CBCentralManager( delegate: centralManagerDelegate, - queue: nil + queue: nil, + options: restorationKey != nil ? [CBCentralManagerOptionRestoreIdentifierKey: restorationKey!] : nil ) } @@ -375,7 +413,13 @@ final class Central { return characteristic } - private enum Failure: Error, CustomStringConvertible { + func hasRestoredPeripheralsPendingDiscovery() -> Bool { + return restoredPeripherals.values.contains(where: { peripheral in + peripheral.status == .pendingDiscovery + }) + } + + public enum Failure: Error, CustomStringConvertible { case notPoweredOn(actualState: CBManagerState) case peripheralIsUnknown(PeripheralID) diff --git a/packages/reactive_ble_mobile/ios/Classes/ReactiveBle/CentralManagerDelegate.swift b/packages/reactive_ble_mobile/ios/Classes/ReactiveBle/CentralManagerDelegate.swift index 22244dcc..7deecc3a 100644 --- a/packages/reactive_ble_mobile/ios/Classes/ReactiveBle/CentralManagerDelegate.swift +++ b/packages/reactive_ble_mobile/ios/Classes/ReactiveBle/CentralManagerDelegate.swift @@ -11,19 +11,23 @@ final class CentralManagerDelegate: NSObject, CBCentralManagerDelegate { typealias StateChangeHandler = (CBManagerState) -> Void typealias DiscoveryHandler = (CBPeripheral, AdvertisementData, RSSI) -> Void typealias ConnectionChangeHandler = (CBPeripheral, ConnectionChange) -> Void + typealias PeripheralsRestoredHandler = ([CBPeripheral]) -> Void private let onStateChange: StateChangeHandler private let onDiscovery: DiscoveryHandler private let onConnectionChange: ConnectionChangeHandler + private let onPeripheralsRestored: PeripheralsRestoredHandler init( onStateChange: @escaping StateChangeHandler, onDiscovery: @escaping DiscoveryHandler, - onConnectionChange: @escaping ConnectionChangeHandler + onConnectionChange: @escaping ConnectionChangeHandler, + onPeripheralsRestored: @escaping PeripheralsRestoredHandler ) { self.onStateChange = onStateChange self.onDiscovery = onDiscovery self.onConnectionChange = onConnectionChange + self.onPeripheralsRestored = onPeripheralsRestored } func centralManagerDidUpdateState(_ central: CBCentralManager) { @@ -45,4 +49,10 @@ final class CentralManagerDelegate: NSObject, CBCentralManagerDelegate { func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) { onConnectionChange(peripheral, .disconnected(error)) } + + func centralManager(_ central: CBCentralManager, willRestoreState dict: [String: Any]) { + if let peripherals = dict[CBCentralManagerRestoredStatePeripheralsKey] as? [CBPeripheral] { + onPeripheralsRestored(peripherals) + } + } } diff --git a/packages/reactive_ble_mobile/lib/src/converter/args_to_protubuf_converter.dart b/packages/reactive_ble_mobile/lib/src/converter/args_to_protubuf_converter.dart index 875c45ec..9513c599 100644 --- a/packages/reactive_ble_mobile/lib/src/converter/args_to_protubuf_converter.dart +++ b/packages/reactive_ble_mobile/lib/src/converter/args_to_protubuf_converter.dart @@ -3,6 +3,8 @@ import 'package:reactive_ble_platform_interface/reactive_ble_platform_interface. import '../generated/bledata.pb.dart' as pb; abstract class ArgsToProtobufConverter { + pb.InitializationRequest createInitializationRequest(String? restorationKey); + pb.ConnectToDeviceRequest createConnectToDeviceArgs( String id, Map>? servicesWithCharacteristicsToDiscover, @@ -16,16 +18,16 @@ abstract class ArgsToProtobufConverter { ); pb.WriteCharacteristicRequest createWriteCharacteristicRequest( - CharacteristicInstance characteristic, + CharacteristicInstance characteristic, List value, ); pb.NotifyCharacteristicRequest createNotifyCharacteristicRequest( - CharacteristicInstance characteristic, + CharacteristicInstance characteristic, ); pb.NotifyNoMoreCharacteristicRequest createNotifyNoMoreCharacteristicRequest( - CharacteristicInstance characteristic, + CharacteristicInstance characteristic, ); pb.NegotiateMtuRequest createNegotiateMtuRequest( @@ -54,6 +56,17 @@ abstract class ArgsToProtobufConverter { class ArgsToProtobufConverterImpl implements ArgsToProtobufConverter { const ArgsToProtobufConverterImpl(); + @override + pb.InitializationRequest createInitializationRequest(String? restorationKey) { + final args = pb.InitializationRequest(); + + if (restorationKey != null) { + args.restorationKey = restorationKey; + } + + return args; + } + @override pb.ConnectToDeviceRequest createConnectToDeviceArgs( String id, diff --git a/packages/reactive_ble_mobile/lib/src/converter/protobuf_converter.dart b/packages/reactive_ble_mobile/lib/src/converter/protobuf_converter.dart index cd223eb2..6f3fa828 100644 --- a/packages/reactive_ble_mobile/lib/src/converter/protobuf_converter.dart +++ b/packages/reactive_ble_mobile/lib/src/converter/protobuf_converter.dart @@ -9,8 +9,12 @@ abstract class ProtobufConverter { ScanResult scanResultFrom(List data); + BondStateUpdate bondUpdateFrom(List data); + ConnectionStateUpdate connectionStateUpdateFrom(List data); + List restoredDevicesFrom(List data); + Result?> clearGattCacheResultFrom( List data, ); @@ -75,6 +79,19 @@ class ProtobufConverterImpl implements ProtobufConverter { ); } + @override + BondStateUpdate bondUpdateFrom(List data) { + final message = pb.BondInfo.fromBuffer(data); + return BondStateUpdate( + deviceId: message.id, + bondState: selectFrom( + DeviceBondState.values, + index: message.bondState, + fallback: (_) => DeviceBondState.unknown, + ), + ); + } + @override ConnectionStateUpdate connectionStateUpdateFrom(List data) { final deviceInfo = pb.DeviceInfo.fromBuffer(data); @@ -94,6 +111,25 @@ class ProtobufConverterImpl implements ProtobufConverter { ); } + @override + List restoredDevicesFrom(List data) { + final collection = pb.RestoredDeviceInfoCollection.fromBuffer(data); + + return collection.devices + .map((info) => RestoredPeripheral( + id: info.id, + name: info.name, + subscriptions: info.subscriptions + .map((address) => QualifiedCharacteristic( + characteristicId: Uuid(address.characteristicUuid.data), + serviceId: Uuid(address.serviceUuid.data), + deviceId: info.id, + )) + .toList(), + )) + .toList(); + } + @override Result?> clearGattCacheResultFrom( List data) { diff --git a/packages/reactive_ble_mobile/lib/src/generated/bledata.pb.dart b/packages/reactive_ble_mobile/lib/src/generated/bledata.pb.dart index e2d1c4b6..9891a605 100644 --- a/packages/reactive_ble_mobile/lib/src/generated/bledata.pb.dart +++ b/packages/reactive_ble_mobile/lib/src/generated/bledata.pb.dart @@ -1,42 +1,97 @@ -/// +// // Generated code. Do not modify. // source: bledata.proto // // @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; -class ScanForDevicesRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ScanForDevicesRequest', createEmptyInstance: create) - ..pc(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'serviceUuids', $pb.PbFieldType.PM, protoName: 'serviceUuids', subBuilder: Uuid.create) - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'scanMode', $pb.PbFieldType.O3, protoName: 'scanMode') - ..aOB(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'requireLocationServicesEnabled', protoName: 'requireLocationServicesEnabled') +class InitializationRequest extends $pb.GeneratedMessage { + factory InitializationRequest({ + $core.String? restorationKey, + }) { + final $result = create(); + if (restorationKey != null) { + $result.restorationKey = restorationKey; + } + return $result; + } + InitializationRequest._() : super(); + factory InitializationRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory InitializationRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'InitializationRequest', createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'restorationKey', protoName: 'restorationKey') ..hasRequiredFields = false ; - ScanForDevicesRequest._() : super(); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + InitializationRequest clone() => InitializationRequest()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + InitializationRequest copyWith(void Function(InitializationRequest) updates) => super.copyWith((message) => updates(message as InitializationRequest)) as InitializationRequest; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static InitializationRequest create() => InitializationRequest._(); + InitializationRequest createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static InitializationRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static InitializationRequest? _defaultInstance; + + @$pb.TagNumber(1) + $core.String get restorationKey => $_getSZ(0); + @$pb.TagNumber(1) + set restorationKey($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) + $core.bool hasRestorationKey() => $_has(0); + @$pb.TagNumber(1) + void clearRestorationKey() => clearField(1); +} + +class ScanForDevicesRequest extends $pb.GeneratedMessage { factory ScanForDevicesRequest({ $core.Iterable? serviceUuids, $core.int? scanMode, $core.bool? requireLocationServicesEnabled, }) { - final _result = create(); + final $result = create(); if (serviceUuids != null) { - _result.serviceUuids.addAll(serviceUuids); + $result.serviceUuids.addAll(serviceUuids); } if (scanMode != null) { - _result.scanMode = scanMode; + $result.scanMode = scanMode; } if (requireLocationServicesEnabled != null) { - _result.requireLocationServicesEnabled = requireLocationServicesEnabled; + $result.requireLocationServicesEnabled = requireLocationServicesEnabled; } - return _result; + return $result; } + ScanForDevicesRequest._() : super(); factory ScanForDevicesRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory ScanForDevicesRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ScanForDevicesRequest', createEmptyInstance: create) + ..pc(1, _omitFieldNames ? '' : 'serviceUuids', $pb.PbFieldType.PM, protoName: 'serviceUuids', subBuilder: Uuid.create) + ..a<$core.int>(2, _omitFieldNames ? '' : 'scanMode', $pb.PbFieldType.O3, protoName: 'scanMode') + ..aOB(3, _omitFieldNames ? '' : 'requireLocationServicesEnabled', protoName: 'requireLocationServicesEnabled') + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -46,8 +101,10 @@ class ScanForDevicesRequest extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - ScanForDevicesRequest copyWith(void Function(ScanForDevicesRequest) updates) => super.copyWith((message) => updates(message as ScanForDevicesRequest)) as ScanForDevicesRequest; // ignore: deprecated_member_use + ScanForDevicesRequest copyWith(void Function(ScanForDevicesRequest) updates) => super.copyWith((message) => updates(message as ScanForDevicesRequest)) as ScanForDevicesRequest; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static ScanForDevicesRequest create() => ScanForDevicesRequest._(); ScanForDevicesRequest createEmptyInstance() => create(); @@ -79,19 +136,6 @@ class ScanForDevicesRequest extends $pb.GeneratedMessage { } class DeviceScanInfo extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'DeviceScanInfo', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id') - ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name') - ..aOM(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'failure', subBuilder: GenericFailure.create) - ..pc(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'serviceData', $pb.PbFieldType.PM, protoName: 'serviceData', subBuilder: ServiceDataEntry.create) - ..a<$core.int>(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'rssi', $pb.PbFieldType.O3) - ..a<$core.List<$core.int>>(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'manufacturerData', $pb.PbFieldType.OY, protoName: 'manufacturerData') - ..pc(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'serviceUuids', $pb.PbFieldType.PM, protoName: 'serviceUuids', subBuilder: Uuid.create) - ..aOM(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'isConnectable', protoName: 'isConnectable', subBuilder: IsConnectable.create) - ..hasRequiredFields = false - ; - - DeviceScanInfo._() : super(); factory DeviceScanInfo({ $core.String? id, $core.String? name, @@ -102,35 +146,49 @@ class DeviceScanInfo extends $pb.GeneratedMessage { $core.Iterable? serviceUuids, IsConnectable? isConnectable, }) { - final _result = create(); + final $result = create(); if (id != null) { - _result.id = id; + $result.id = id; } if (name != null) { - _result.name = name; + $result.name = name; } if (failure != null) { - _result.failure = failure; + $result.failure = failure; } if (serviceData != null) { - _result.serviceData.addAll(serviceData); + $result.serviceData.addAll(serviceData); } if (rssi != null) { - _result.rssi = rssi; + $result.rssi = rssi; } if (manufacturerData != null) { - _result.manufacturerData = manufacturerData; + $result.manufacturerData = manufacturerData; } if (serviceUuids != null) { - _result.serviceUuids.addAll(serviceUuids); + $result.serviceUuids.addAll(serviceUuids); } if (isConnectable != null) { - _result.isConnectable = isConnectable; + $result.isConnectable = isConnectable; } - return _result; + return $result; } + DeviceScanInfo._() : super(); factory DeviceScanInfo.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory DeviceScanInfo.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'DeviceScanInfo', createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'id') + ..aOS(2, _omitFieldNames ? '' : 'name') + ..aOM(3, _omitFieldNames ? '' : 'failure', subBuilder: GenericFailure.create) + ..pc(4, _omitFieldNames ? '' : 'serviceData', $pb.PbFieldType.PM, protoName: 'serviceData', subBuilder: ServiceDataEntry.create) + ..a<$core.int>(5, _omitFieldNames ? '' : 'rssi', $pb.PbFieldType.O3) + ..a<$core.List<$core.int>>(6, _omitFieldNames ? '' : 'manufacturerData', $pb.PbFieldType.OY, protoName: 'manufacturerData') + ..pc(7, _omitFieldNames ? '' : 'serviceUuids', $pb.PbFieldType.PM, protoName: 'serviceUuids', subBuilder: Uuid.create) + ..aOM(8, _omitFieldNames ? '' : 'isConnectable', protoName: 'isConnectable', subBuilder: IsConnectable.create) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -140,8 +198,10 @@ class DeviceScanInfo extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - DeviceScanInfo copyWith(void Function(DeviceScanInfo) updates) => super.copyWith((message) => updates(message as DeviceScanInfo)) as DeviceScanInfo; // ignore: deprecated_member_use + DeviceScanInfo copyWith(void Function(DeviceScanInfo) updates) => super.copyWith((message) => updates(message as DeviceScanInfo)) as DeviceScanInfo; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static DeviceScanInfo create() => DeviceScanInfo._(); DeviceScanInfo createEmptyInstance() => create(); @@ -216,33 +276,34 @@ class DeviceScanInfo extends $pb.GeneratedMessage { } class ConnectToDeviceRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ConnectToDeviceRequest', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceId', protoName: 'deviceId') - ..aOM(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'servicesWithCharacteristicsToDiscover', protoName: 'servicesWithCharacteristicsToDiscover', subBuilder: ServicesWithCharacteristics.create) - ..a<$core.int>(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'timeoutInMs', $pb.PbFieldType.O3, protoName: 'timeoutInMs') - ..hasRequiredFields = false - ; - - ConnectToDeviceRequest._() : super(); factory ConnectToDeviceRequest({ $core.String? deviceId, ServicesWithCharacteristics? servicesWithCharacteristicsToDiscover, $core.int? timeoutInMs, }) { - final _result = create(); + final $result = create(); if (deviceId != null) { - _result.deviceId = deviceId; + $result.deviceId = deviceId; } if (servicesWithCharacteristicsToDiscover != null) { - _result.servicesWithCharacteristicsToDiscover = servicesWithCharacteristicsToDiscover; + $result.servicesWithCharacteristicsToDiscover = servicesWithCharacteristicsToDiscover; } if (timeoutInMs != null) { - _result.timeoutInMs = timeoutInMs; + $result.timeoutInMs = timeoutInMs; } - return _result; + return $result; } + ConnectToDeviceRequest._() : super(); factory ConnectToDeviceRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory ConnectToDeviceRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ConnectToDeviceRequest', createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'deviceId', protoName: 'deviceId') + ..aOM(2, _omitFieldNames ? '' : 'servicesWithCharacteristicsToDiscover', protoName: 'servicesWithCharacteristicsToDiscover', subBuilder: ServicesWithCharacteristics.create) + ..a<$core.int>(3, _omitFieldNames ? '' : 'timeoutInMs', $pb.PbFieldType.O3, protoName: 'timeoutInMs') + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -252,8 +313,10 @@ class ConnectToDeviceRequest extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - ConnectToDeviceRequest copyWith(void Function(ConnectToDeviceRequest) updates) => super.copyWith((message) => updates(message as ConnectToDeviceRequest)) as ConnectToDeviceRequest; // ignore: deprecated_member_use + ConnectToDeviceRequest copyWith(void Function(ConnectToDeviceRequest) updates) => super.copyWith((message) => updates(message as ConnectToDeviceRequest)) as ConnectToDeviceRequest; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static ConnectToDeviceRequest create() => ConnectToDeviceRequest._(); ConnectToDeviceRequest createEmptyInstance() => create(); @@ -292,34 +355,99 @@ class ConnectToDeviceRequest extends $pb.GeneratedMessage { void clearTimeoutInMs() => clearField(3); } -class DeviceInfo extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'DeviceInfo', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id') - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'connectionState', $pb.PbFieldType.O3, protoName: 'connectionState') - ..aOM(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'failure', subBuilder: GenericFailure.create) +class BondInfo extends $pb.GeneratedMessage { + factory BondInfo({ + $core.String? id, + $core.int? bondState, + }) { + final $result = create(); + if (id != null) { + $result.id = id; + } + if (bondState != null) { + $result.bondState = bondState; + } + return $result; + } + BondInfo._() : super(); + factory BondInfo.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory BondInfo.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'BondInfo', createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'id') + ..a<$core.int>(2, _omitFieldNames ? '' : 'bondState', $pb.PbFieldType.O3, protoName: 'bondState') ..hasRequiredFields = false ; - DeviceInfo._() : super(); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + BondInfo clone() => BondInfo()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + BondInfo copyWith(void Function(BondInfo) updates) => super.copyWith((message) => updates(message as BondInfo)) as BondInfo; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static BondInfo create() => BondInfo._(); + BondInfo createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static BondInfo getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static BondInfo? _defaultInstance; + + @$pb.TagNumber(1) + $core.String get id => $_getSZ(0); + @$pb.TagNumber(1) + set id($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) + $core.bool hasId() => $_has(0); + @$pb.TagNumber(1) + void clearId() => clearField(1); + + @$pb.TagNumber(2) + $core.int get bondState => $_getIZ(1); + @$pb.TagNumber(2) + set bondState($core.int v) { $_setSignedInt32(1, v); } + @$pb.TagNumber(2) + $core.bool hasBondState() => $_has(1); + @$pb.TagNumber(2) + void clearBondState() => clearField(2); +} + +class DeviceInfo extends $pb.GeneratedMessage { factory DeviceInfo({ $core.String? id, $core.int? connectionState, GenericFailure? failure, }) { - final _result = create(); + final $result = create(); if (id != null) { - _result.id = id; + $result.id = id; } if (connectionState != null) { - _result.connectionState = connectionState; + $result.connectionState = connectionState; } if (failure != null) { - _result.failure = failure; + $result.failure = failure; } - return _result; + return $result; } + DeviceInfo._() : super(); factory DeviceInfo.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory DeviceInfo.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'DeviceInfo', createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'id') + ..a<$core.int>(2, _omitFieldNames ? '' : 'connectionState', $pb.PbFieldType.O3, protoName: 'connectionState') + ..aOM(3, _omitFieldNames ? '' : 'failure', subBuilder: GenericFailure.create) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -329,8 +457,10 @@ class DeviceInfo extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - DeviceInfo copyWith(void Function(DeviceInfo) updates) => super.copyWith((message) => updates(message as DeviceInfo)) as DeviceInfo; // ignore: deprecated_member_use + DeviceInfo copyWith(void Function(DeviceInfo) updates) => super.copyWith((message) => updates(message as DeviceInfo)) as DeviceInfo; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static DeviceInfo create() => DeviceInfo._(); DeviceInfo createEmptyInstance() => create(); @@ -369,24 +499,141 @@ class DeviceInfo extends $pb.GeneratedMessage { GenericFailure ensureFailure() => $_ensure(2); } -class DisconnectFromDeviceRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'DisconnectFromDeviceRequest', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceId', protoName: 'deviceId') +class RestoredDeviceInfo extends $pb.GeneratedMessage { + factory RestoredDeviceInfo({ + $core.String? id, + $core.String? name, + $core.Iterable? subscriptions, + }) { + final $result = create(); + if (id != null) { + $result.id = id; + } + if (name != null) { + $result.name = name; + } + if (subscriptions != null) { + $result.subscriptions.addAll(subscriptions); + } + return $result; + } + RestoredDeviceInfo._() : super(); + factory RestoredDeviceInfo.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory RestoredDeviceInfo.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'RestoredDeviceInfo', createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'id') + ..aOS(2, _omitFieldNames ? '' : 'name') + ..pc(3, _omitFieldNames ? '' : 'subscriptions', $pb.PbFieldType.PM, subBuilder: CharacteristicAddress.create) ..hasRequiredFields = false ; - DisconnectFromDeviceRequest._() : super(); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + RestoredDeviceInfo clone() => RestoredDeviceInfo()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + RestoredDeviceInfo copyWith(void Function(RestoredDeviceInfo) updates) => super.copyWith((message) => updates(message as RestoredDeviceInfo)) as RestoredDeviceInfo; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static RestoredDeviceInfo create() => RestoredDeviceInfo._(); + RestoredDeviceInfo createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static RestoredDeviceInfo getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static RestoredDeviceInfo? _defaultInstance; + + @$pb.TagNumber(1) + $core.String get id => $_getSZ(0); + @$pb.TagNumber(1) + set id($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) + $core.bool hasId() => $_has(0); + @$pb.TagNumber(1) + void clearId() => clearField(1); + + @$pb.TagNumber(2) + $core.String get name => $_getSZ(1); + @$pb.TagNumber(2) + set name($core.String v) { $_setString(1, v); } + @$pb.TagNumber(2) + $core.bool hasName() => $_has(1); + @$pb.TagNumber(2) + void clearName() => clearField(2); + + @$pb.TagNumber(3) + $core.List get subscriptions => $_getList(2); +} + +class RestoredDeviceInfoCollection extends $pb.GeneratedMessage { + factory RestoredDeviceInfoCollection({ + $core.Iterable? devices, + }) { + final $result = create(); + if (devices != null) { + $result.devices.addAll(devices); + } + return $result; + } + RestoredDeviceInfoCollection._() : super(); + factory RestoredDeviceInfoCollection.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory RestoredDeviceInfoCollection.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'RestoredDeviceInfoCollection', createEmptyInstance: create) + ..pc(1, _omitFieldNames ? '' : 'devices', $pb.PbFieldType.PM, subBuilder: RestoredDeviceInfo.create) + ..hasRequiredFields = false + ; + + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + RestoredDeviceInfoCollection clone() => RestoredDeviceInfoCollection()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + RestoredDeviceInfoCollection copyWith(void Function(RestoredDeviceInfoCollection) updates) => super.copyWith((message) => updates(message as RestoredDeviceInfoCollection)) as RestoredDeviceInfoCollection; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static RestoredDeviceInfoCollection create() => RestoredDeviceInfoCollection._(); + RestoredDeviceInfoCollection createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static RestoredDeviceInfoCollection getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static RestoredDeviceInfoCollection? _defaultInstance; + + @$pb.TagNumber(1) + $core.List get devices => $_getList(0); +} + +class DisconnectFromDeviceRequest extends $pb.GeneratedMessage { factory DisconnectFromDeviceRequest({ $core.String? deviceId, }) { - final _result = create(); + final $result = create(); if (deviceId != null) { - _result.deviceId = deviceId; + $result.deviceId = deviceId; } - return _result; + return $result; } + DisconnectFromDeviceRequest._() : super(); factory DisconnectFromDeviceRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory DisconnectFromDeviceRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'DisconnectFromDeviceRequest', createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'deviceId', protoName: 'deviceId') + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -396,8 +643,10 @@ class DisconnectFromDeviceRequest extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - DisconnectFromDeviceRequest copyWith(void Function(DisconnectFromDeviceRequest) updates) => super.copyWith((message) => updates(message as DisconnectFromDeviceRequest)) as DisconnectFromDeviceRequest; // ignore: deprecated_member_use + DisconnectFromDeviceRequest copyWith(void Function(DisconnectFromDeviceRequest) updates) => super.copyWith((message) => updates(message as DisconnectFromDeviceRequest)) as DisconnectFromDeviceRequest; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static DisconnectFromDeviceRequest create() => DisconnectFromDeviceRequest._(); DisconnectFromDeviceRequest createEmptyInstance() => create(); @@ -417,23 +666,24 @@ class DisconnectFromDeviceRequest extends $pb.GeneratedMessage { } class ClearGattCacheRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ClearGattCacheRequest', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceId', protoName: 'deviceId') - ..hasRequiredFields = false - ; - - ClearGattCacheRequest._() : super(); factory ClearGattCacheRequest({ $core.String? deviceId, }) { - final _result = create(); + final $result = create(); if (deviceId != null) { - _result.deviceId = deviceId; + $result.deviceId = deviceId; } - return _result; + return $result; } + ClearGattCacheRequest._() : super(); factory ClearGattCacheRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory ClearGattCacheRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ClearGattCacheRequest', createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'deviceId', protoName: 'deviceId') + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -443,8 +693,10 @@ class ClearGattCacheRequest extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - ClearGattCacheRequest copyWith(void Function(ClearGattCacheRequest) updates) => super.copyWith((message) => updates(message as ClearGattCacheRequest)) as ClearGattCacheRequest; // ignore: deprecated_member_use + ClearGattCacheRequest copyWith(void Function(ClearGattCacheRequest) updates) => super.copyWith((message) => updates(message as ClearGattCacheRequest)) as ClearGattCacheRequest; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static ClearGattCacheRequest create() => ClearGattCacheRequest._(); ClearGattCacheRequest createEmptyInstance() => create(); @@ -464,23 +716,24 @@ class ClearGattCacheRequest extends $pb.GeneratedMessage { } class ClearGattCacheInfo extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ClearGattCacheInfo', createEmptyInstance: create) - ..aOM(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'failure', subBuilder: GenericFailure.create) - ..hasRequiredFields = false - ; - - ClearGattCacheInfo._() : super(); factory ClearGattCacheInfo({ GenericFailure? failure, }) { - final _result = create(); + final $result = create(); if (failure != null) { - _result.failure = failure; + $result.failure = failure; } - return _result; + return $result; } + ClearGattCacheInfo._() : super(); factory ClearGattCacheInfo.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory ClearGattCacheInfo.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ClearGattCacheInfo', createEmptyInstance: create) + ..aOM(1, _omitFieldNames ? '' : 'failure', subBuilder: GenericFailure.create) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -490,8 +743,10 @@ class ClearGattCacheInfo extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - ClearGattCacheInfo copyWith(void Function(ClearGattCacheInfo) updates) => super.copyWith((message) => updates(message as ClearGattCacheInfo)) as ClearGattCacheInfo; // ignore: deprecated_member_use + ClearGattCacheInfo copyWith(void Function(ClearGattCacheInfo) updates) => super.copyWith((message) => updates(message as ClearGattCacheInfo)) as ClearGattCacheInfo; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static ClearGattCacheInfo create() => ClearGattCacheInfo._(); ClearGattCacheInfo createEmptyInstance() => create(); @@ -513,23 +768,24 @@ class ClearGattCacheInfo extends $pb.GeneratedMessage { } class NotifyCharacteristicRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'NotifyCharacteristicRequest', createEmptyInstance: create) - ..aOM(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'characteristic', subBuilder: CharacteristicAddress.create) - ..hasRequiredFields = false - ; - - NotifyCharacteristicRequest._() : super(); factory NotifyCharacteristicRequest({ CharacteristicAddress? characteristic, }) { - final _result = create(); + final $result = create(); if (characteristic != null) { - _result.characteristic = characteristic; + $result.characteristic = characteristic; } - return _result; + return $result; } + NotifyCharacteristicRequest._() : super(); factory NotifyCharacteristicRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory NotifyCharacteristicRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'NotifyCharacteristicRequest', createEmptyInstance: create) + ..aOM(1, _omitFieldNames ? '' : 'characteristic', subBuilder: CharacteristicAddress.create) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -539,8 +795,10 @@ class NotifyCharacteristicRequest extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - NotifyCharacteristicRequest copyWith(void Function(NotifyCharacteristicRequest) updates) => super.copyWith((message) => updates(message as NotifyCharacteristicRequest)) as NotifyCharacteristicRequest; // ignore: deprecated_member_use + NotifyCharacteristicRequest copyWith(void Function(NotifyCharacteristicRequest) updates) => super.copyWith((message) => updates(message as NotifyCharacteristicRequest)) as NotifyCharacteristicRequest; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static NotifyCharacteristicRequest create() => NotifyCharacteristicRequest._(); NotifyCharacteristicRequest createEmptyInstance() => create(); @@ -562,23 +820,24 @@ class NotifyCharacteristicRequest extends $pb.GeneratedMessage { } class NotifyNoMoreCharacteristicRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'NotifyNoMoreCharacteristicRequest', createEmptyInstance: create) - ..aOM(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'characteristic', subBuilder: CharacteristicAddress.create) - ..hasRequiredFields = false - ; - - NotifyNoMoreCharacteristicRequest._() : super(); factory NotifyNoMoreCharacteristicRequest({ CharacteristicAddress? characteristic, }) { - final _result = create(); + final $result = create(); if (characteristic != null) { - _result.characteristic = characteristic; + $result.characteristic = characteristic; } - return _result; + return $result; } + NotifyNoMoreCharacteristicRequest._() : super(); factory NotifyNoMoreCharacteristicRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory NotifyNoMoreCharacteristicRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'NotifyNoMoreCharacteristicRequest', createEmptyInstance: create) + ..aOM(1, _omitFieldNames ? '' : 'characteristic', subBuilder: CharacteristicAddress.create) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -588,8 +847,10 @@ class NotifyNoMoreCharacteristicRequest extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - NotifyNoMoreCharacteristicRequest copyWith(void Function(NotifyNoMoreCharacteristicRequest) updates) => super.copyWith((message) => updates(message as NotifyNoMoreCharacteristicRequest)) as NotifyNoMoreCharacteristicRequest; // ignore: deprecated_member_use + NotifyNoMoreCharacteristicRequest copyWith(void Function(NotifyNoMoreCharacteristicRequest) updates) => super.copyWith((message) => updates(message as NotifyNoMoreCharacteristicRequest)) as NotifyNoMoreCharacteristicRequest; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static NotifyNoMoreCharacteristicRequest create() => NotifyNoMoreCharacteristicRequest._(); NotifyNoMoreCharacteristicRequest createEmptyInstance() => create(); @@ -611,23 +872,24 @@ class NotifyNoMoreCharacteristicRequest extends $pb.GeneratedMessage { } class ReadCharacteristicRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ReadCharacteristicRequest', createEmptyInstance: create) - ..aOM(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'characteristic', subBuilder: CharacteristicAddress.create) - ..hasRequiredFields = false - ; - - ReadCharacteristicRequest._() : super(); factory ReadCharacteristicRequest({ CharacteristicAddress? characteristic, }) { - final _result = create(); + final $result = create(); if (characteristic != null) { - _result.characteristic = characteristic; + $result.characteristic = characteristic; } - return _result; + return $result; } + ReadCharacteristicRequest._() : super(); factory ReadCharacteristicRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory ReadCharacteristicRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ReadCharacteristicRequest', createEmptyInstance: create) + ..aOM(1, _omitFieldNames ? '' : 'characteristic', subBuilder: CharacteristicAddress.create) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -637,8 +899,10 @@ class ReadCharacteristicRequest extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - ReadCharacteristicRequest copyWith(void Function(ReadCharacteristicRequest) updates) => super.copyWith((message) => updates(message as ReadCharacteristicRequest)) as ReadCharacteristicRequest; // ignore: deprecated_member_use + ReadCharacteristicRequest copyWith(void Function(ReadCharacteristicRequest) updates) => super.copyWith((message) => updates(message as ReadCharacteristicRequest)) as ReadCharacteristicRequest; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static ReadCharacteristicRequest create() => ReadCharacteristicRequest._(); ReadCharacteristicRequest createEmptyInstance() => create(); @@ -660,33 +924,34 @@ class ReadCharacteristicRequest extends $pb.GeneratedMessage { } class CharacteristicValueInfo extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CharacteristicValueInfo', createEmptyInstance: create) - ..aOM(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'characteristic', subBuilder: CharacteristicAddress.create) - ..a<$core.List<$core.int>>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'value', $pb.PbFieldType.OY) - ..aOM(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'failure', subBuilder: GenericFailure.create) - ..hasRequiredFields = false - ; - - CharacteristicValueInfo._() : super(); factory CharacteristicValueInfo({ CharacteristicAddress? characteristic, $core.List<$core.int>? value, GenericFailure? failure, }) { - final _result = create(); + final $result = create(); if (characteristic != null) { - _result.characteristic = characteristic; + $result.characteristic = characteristic; } if (value != null) { - _result.value = value; + $result.value = value; } if (failure != null) { - _result.failure = failure; + $result.failure = failure; } - return _result; + return $result; } + CharacteristicValueInfo._() : super(); factory CharacteristicValueInfo.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory CharacteristicValueInfo.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'CharacteristicValueInfo', createEmptyInstance: create) + ..aOM(1, _omitFieldNames ? '' : 'characteristic', subBuilder: CharacteristicAddress.create) + ..a<$core.List<$core.int>>(2, _omitFieldNames ? '' : 'value', $pb.PbFieldType.OY) + ..aOM(3, _omitFieldNames ? '' : 'failure', subBuilder: GenericFailure.create) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -696,8 +961,10 @@ class CharacteristicValueInfo extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - CharacteristicValueInfo copyWith(void Function(CharacteristicValueInfo) updates) => super.copyWith((message) => updates(message as CharacteristicValueInfo)) as CharacteristicValueInfo; // ignore: deprecated_member_use + CharacteristicValueInfo copyWith(void Function(CharacteristicValueInfo) updates) => super.copyWith((message) => updates(message as CharacteristicValueInfo)) as CharacteristicValueInfo; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static CharacteristicValueInfo create() => CharacteristicValueInfo._(); CharacteristicValueInfo createEmptyInstance() => create(); @@ -739,28 +1006,29 @@ class CharacteristicValueInfo extends $pb.GeneratedMessage { } class WriteCharacteristicRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'WriteCharacteristicRequest', createEmptyInstance: create) - ..aOM(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'characteristic', subBuilder: CharacteristicAddress.create) - ..a<$core.List<$core.int>>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'value', $pb.PbFieldType.OY) - ..hasRequiredFields = false - ; - - WriteCharacteristicRequest._() : super(); factory WriteCharacteristicRequest({ CharacteristicAddress? characteristic, $core.List<$core.int>? value, }) { - final _result = create(); + final $result = create(); if (characteristic != null) { - _result.characteristic = characteristic; + $result.characteristic = characteristic; } if (value != null) { - _result.value = value; + $result.value = value; } - return _result; + return $result; } + WriteCharacteristicRequest._() : super(); factory WriteCharacteristicRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory WriteCharacteristicRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'WriteCharacteristicRequest', createEmptyInstance: create) + ..aOM(1, _omitFieldNames ? '' : 'characteristic', subBuilder: CharacteristicAddress.create) + ..a<$core.List<$core.int>>(2, _omitFieldNames ? '' : 'value', $pb.PbFieldType.OY) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -770,8 +1038,10 @@ class WriteCharacteristicRequest extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - WriteCharacteristicRequest copyWith(void Function(WriteCharacteristicRequest) updates) => super.copyWith((message) => updates(message as WriteCharacteristicRequest)) as WriteCharacteristicRequest; // ignore: deprecated_member_use + WriteCharacteristicRequest copyWith(void Function(WriteCharacteristicRequest) updates) => super.copyWith((message) => updates(message as WriteCharacteristicRequest)) as WriteCharacteristicRequest; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static WriteCharacteristicRequest create() => WriteCharacteristicRequest._(); WriteCharacteristicRequest createEmptyInstance() => create(); @@ -802,28 +1072,29 @@ class WriteCharacteristicRequest extends $pb.GeneratedMessage { } class WriteCharacteristicInfo extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'WriteCharacteristicInfo', createEmptyInstance: create) - ..aOM(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'characteristic', subBuilder: CharacteristicAddress.create) - ..aOM(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'failure', subBuilder: GenericFailure.create) - ..hasRequiredFields = false - ; - - WriteCharacteristicInfo._() : super(); factory WriteCharacteristicInfo({ CharacteristicAddress? characteristic, GenericFailure? failure, }) { - final _result = create(); + final $result = create(); if (characteristic != null) { - _result.characteristic = characteristic; + $result.characteristic = characteristic; } if (failure != null) { - _result.failure = failure; + $result.failure = failure; } - return _result; + return $result; } + WriteCharacteristicInfo._() : super(); factory WriteCharacteristicInfo.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory WriteCharacteristicInfo.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'WriteCharacteristicInfo', createEmptyInstance: create) + ..aOM(1, _omitFieldNames ? '' : 'characteristic', subBuilder: CharacteristicAddress.create) + ..aOM(3, _omitFieldNames ? '' : 'failure', subBuilder: GenericFailure.create) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -833,8 +1104,10 @@ class WriteCharacteristicInfo extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - WriteCharacteristicInfo copyWith(void Function(WriteCharacteristicInfo) updates) => super.copyWith((message) => updates(message as WriteCharacteristicInfo)) as WriteCharacteristicInfo; // ignore: deprecated_member_use + WriteCharacteristicInfo copyWith(void Function(WriteCharacteristicInfo) updates) => super.copyWith((message) => updates(message as WriteCharacteristicInfo)) as WriteCharacteristicInfo; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static WriteCharacteristicInfo create() => WriteCharacteristicInfo._(); WriteCharacteristicInfo createEmptyInstance() => create(); @@ -867,28 +1140,29 @@ class WriteCharacteristicInfo extends $pb.GeneratedMessage { } class NegotiateMtuRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'NegotiateMtuRequest', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceId', protoName: 'deviceId') - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'mtuSize', $pb.PbFieldType.O3, protoName: 'mtuSize') - ..hasRequiredFields = false - ; - - NegotiateMtuRequest._() : super(); factory NegotiateMtuRequest({ $core.String? deviceId, $core.int? mtuSize, }) { - final _result = create(); + final $result = create(); if (deviceId != null) { - _result.deviceId = deviceId; + $result.deviceId = deviceId; } if (mtuSize != null) { - _result.mtuSize = mtuSize; + $result.mtuSize = mtuSize; } - return _result; + return $result; } + NegotiateMtuRequest._() : super(); factory NegotiateMtuRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory NegotiateMtuRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'NegotiateMtuRequest', createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'deviceId', protoName: 'deviceId') + ..a<$core.int>(2, _omitFieldNames ? '' : 'mtuSize', $pb.PbFieldType.O3, protoName: 'mtuSize') + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -898,8 +1172,10 @@ class NegotiateMtuRequest extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - NegotiateMtuRequest copyWith(void Function(NegotiateMtuRequest) updates) => super.copyWith((message) => updates(message as NegotiateMtuRequest)) as NegotiateMtuRequest; // ignore: deprecated_member_use + NegotiateMtuRequest copyWith(void Function(NegotiateMtuRequest) updates) => super.copyWith((message) => updates(message as NegotiateMtuRequest)) as NegotiateMtuRequest; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static NegotiateMtuRequest create() => NegotiateMtuRequest._(); NegotiateMtuRequest createEmptyInstance() => create(); @@ -928,33 +1204,34 @@ class NegotiateMtuRequest extends $pb.GeneratedMessage { } class NegotiateMtuInfo extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'NegotiateMtuInfo', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceId', protoName: 'deviceId') - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'mtuSize', $pb.PbFieldType.O3, protoName: 'mtuSize') - ..aOM(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'failure', subBuilder: GenericFailure.create) - ..hasRequiredFields = false - ; - - NegotiateMtuInfo._() : super(); factory NegotiateMtuInfo({ $core.String? deviceId, $core.int? mtuSize, GenericFailure? failure, }) { - final _result = create(); + final $result = create(); if (deviceId != null) { - _result.deviceId = deviceId; + $result.deviceId = deviceId; } if (mtuSize != null) { - _result.mtuSize = mtuSize; + $result.mtuSize = mtuSize; } if (failure != null) { - _result.failure = failure; + $result.failure = failure; } - return _result; + return $result; } + NegotiateMtuInfo._() : super(); factory NegotiateMtuInfo.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory NegotiateMtuInfo.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'NegotiateMtuInfo', createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'deviceId', protoName: 'deviceId') + ..a<$core.int>(2, _omitFieldNames ? '' : 'mtuSize', $pb.PbFieldType.O3, protoName: 'mtuSize') + ..aOM(3, _omitFieldNames ? '' : 'failure', subBuilder: GenericFailure.create) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -964,8 +1241,10 @@ class NegotiateMtuInfo extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - NegotiateMtuInfo copyWith(void Function(NegotiateMtuInfo) updates) => super.copyWith((message) => updates(message as NegotiateMtuInfo)) as NegotiateMtuInfo; // ignore: deprecated_member_use + NegotiateMtuInfo copyWith(void Function(NegotiateMtuInfo) updates) => super.copyWith((message) => updates(message as NegotiateMtuInfo)) as NegotiateMtuInfo; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static NegotiateMtuInfo create() => NegotiateMtuInfo._(); NegotiateMtuInfo createEmptyInstance() => create(); @@ -1005,23 +1284,24 @@ class NegotiateMtuInfo extends $pb.GeneratedMessage { } class BleStatusInfo extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'BleStatusInfo', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'status', $pb.PbFieldType.O3) - ..hasRequiredFields = false - ; - - BleStatusInfo._() : super(); factory BleStatusInfo({ $core.int? status, }) { - final _result = create(); + final $result = create(); if (status != null) { - _result.status = status; + $result.status = status; } - return _result; + return $result; } + BleStatusInfo._() : super(); factory BleStatusInfo.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory BleStatusInfo.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'BleStatusInfo', createEmptyInstance: create) + ..a<$core.int>(1, _omitFieldNames ? '' : 'status', $pb.PbFieldType.O3) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -1031,8 +1311,10 @@ class BleStatusInfo extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - BleStatusInfo copyWith(void Function(BleStatusInfo) updates) => super.copyWith((message) => updates(message as BleStatusInfo)) as BleStatusInfo; // ignore: deprecated_member_use + BleStatusInfo copyWith(void Function(BleStatusInfo) updates) => super.copyWith((message) => updates(message as BleStatusInfo)) as BleStatusInfo; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static BleStatusInfo create() => BleStatusInfo._(); BleStatusInfo createEmptyInstance() => create(); @@ -1052,28 +1334,29 @@ class BleStatusInfo extends $pb.GeneratedMessage { } class ChangeConnectionPriorityRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ChangeConnectionPriorityRequest', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceId', protoName: 'deviceId') - ..a<$core.int>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'priority', $pb.PbFieldType.O3) - ..hasRequiredFields = false - ; - - ChangeConnectionPriorityRequest._() : super(); factory ChangeConnectionPriorityRequest({ $core.String? deviceId, $core.int? priority, }) { - final _result = create(); + final $result = create(); if (deviceId != null) { - _result.deviceId = deviceId; + $result.deviceId = deviceId; } if (priority != null) { - _result.priority = priority; + $result.priority = priority; } - return _result; + return $result; } + ChangeConnectionPriorityRequest._() : super(); factory ChangeConnectionPriorityRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory ChangeConnectionPriorityRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ChangeConnectionPriorityRequest', createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'deviceId', protoName: 'deviceId') + ..a<$core.int>(2, _omitFieldNames ? '' : 'priority', $pb.PbFieldType.O3) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -1083,8 +1366,10 @@ class ChangeConnectionPriorityRequest extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - ChangeConnectionPriorityRequest copyWith(void Function(ChangeConnectionPriorityRequest) updates) => super.copyWith((message) => updates(message as ChangeConnectionPriorityRequest)) as ChangeConnectionPriorityRequest; // ignore: deprecated_member_use + ChangeConnectionPriorityRequest copyWith(void Function(ChangeConnectionPriorityRequest) updates) => super.copyWith((message) => updates(message as ChangeConnectionPriorityRequest)) as ChangeConnectionPriorityRequest; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static ChangeConnectionPriorityRequest create() => ChangeConnectionPriorityRequest._(); ChangeConnectionPriorityRequest createEmptyInstance() => create(); @@ -1113,28 +1398,29 @@ class ChangeConnectionPriorityRequest extends $pb.GeneratedMessage { } class ChangeConnectionPriorityInfo extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ChangeConnectionPriorityInfo', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceId', protoName: 'deviceId') - ..aOM(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'failure', subBuilder: GenericFailure.create) - ..hasRequiredFields = false - ; - - ChangeConnectionPriorityInfo._() : super(); factory ChangeConnectionPriorityInfo({ $core.String? deviceId, GenericFailure? failure, }) { - final _result = create(); + final $result = create(); if (deviceId != null) { - _result.deviceId = deviceId; + $result.deviceId = deviceId; } if (failure != null) { - _result.failure = failure; + $result.failure = failure; } - return _result; + return $result; } + ChangeConnectionPriorityInfo._() : super(); factory ChangeConnectionPriorityInfo.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory ChangeConnectionPriorityInfo.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ChangeConnectionPriorityInfo', createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'deviceId', protoName: 'deviceId') + ..aOM(2, _omitFieldNames ? '' : 'failure', subBuilder: GenericFailure.create) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -1144,8 +1430,10 @@ class ChangeConnectionPriorityInfo extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - ChangeConnectionPriorityInfo copyWith(void Function(ChangeConnectionPriorityInfo) updates) => super.copyWith((message) => updates(message as ChangeConnectionPriorityInfo)) as ChangeConnectionPriorityInfo; // ignore: deprecated_member_use + ChangeConnectionPriorityInfo copyWith(void Function(ChangeConnectionPriorityInfo) updates) => super.copyWith((message) => updates(message as ChangeConnectionPriorityInfo)) as ChangeConnectionPriorityInfo; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static ChangeConnectionPriorityInfo create() => ChangeConnectionPriorityInfo._(); ChangeConnectionPriorityInfo createEmptyInstance() => create(); @@ -1176,16 +1464,6 @@ class ChangeConnectionPriorityInfo extends $pb.GeneratedMessage { } class CharacteristicAddress extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CharacteristicAddress', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceId', protoName: 'deviceId') - ..aOM(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'serviceUuid', protoName: 'serviceUuid', subBuilder: Uuid.create) - ..aOM(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'characteristicUuid', protoName: 'characteristicUuid', subBuilder: Uuid.create) - ..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'serviceInstanceId', protoName: 'serviceInstanceId') - ..aOS(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'characteristicInstanceId', protoName: 'characteristicInstanceId') - ..hasRequiredFields = false - ; - - CharacteristicAddress._() : super(); factory CharacteristicAddress({ $core.String? deviceId, Uuid? serviceUuid, @@ -1193,26 +1471,37 @@ class CharacteristicAddress extends $pb.GeneratedMessage { $core.String? serviceInstanceId, $core.String? characteristicInstanceId, }) { - final _result = create(); + final $result = create(); if (deviceId != null) { - _result.deviceId = deviceId; + $result.deviceId = deviceId; } if (serviceUuid != null) { - _result.serviceUuid = serviceUuid; + $result.serviceUuid = serviceUuid; } if (characteristicUuid != null) { - _result.characteristicUuid = characteristicUuid; + $result.characteristicUuid = characteristicUuid; } if (serviceInstanceId != null) { - _result.serviceInstanceId = serviceInstanceId; + $result.serviceInstanceId = serviceInstanceId; } if (characteristicInstanceId != null) { - _result.characteristicInstanceId = characteristicInstanceId; + $result.characteristicInstanceId = characteristicInstanceId; } - return _result; + return $result; } + CharacteristicAddress._() : super(); factory CharacteristicAddress.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory CharacteristicAddress.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'CharacteristicAddress', createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'deviceId', protoName: 'deviceId') + ..aOM(2, _omitFieldNames ? '' : 'serviceUuid', protoName: 'serviceUuid', subBuilder: Uuid.create) + ..aOM(3, _omitFieldNames ? '' : 'characteristicUuid', protoName: 'characteristicUuid', subBuilder: Uuid.create) + ..aOS(4, _omitFieldNames ? '' : 'serviceInstanceId', protoName: 'serviceInstanceId') + ..aOS(5, _omitFieldNames ? '' : 'characteristicInstanceId', protoName: 'characteristicInstanceId') + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -1222,8 +1511,10 @@ class CharacteristicAddress extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - CharacteristicAddress copyWith(void Function(CharacteristicAddress) updates) => super.copyWith((message) => updates(message as CharacteristicAddress)) as CharacteristicAddress; // ignore: deprecated_member_use + CharacteristicAddress copyWith(void Function(CharacteristicAddress) updates) => super.copyWith((message) => updates(message as CharacteristicAddress)) as CharacteristicAddress; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static CharacteristicAddress create() => CharacteristicAddress._(); CharacteristicAddress createEmptyInstance() => create(); @@ -1283,28 +1574,29 @@ class CharacteristicAddress extends $pb.GeneratedMessage { } class ServiceDataEntry extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ServiceDataEntry', createEmptyInstance: create) - ..aOM(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'serviceUuid', protoName: 'serviceUuid', subBuilder: Uuid.create) - ..a<$core.List<$core.int>>(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'data', $pb.PbFieldType.OY) - ..hasRequiredFields = false - ; - - ServiceDataEntry._() : super(); factory ServiceDataEntry({ Uuid? serviceUuid, $core.List<$core.int>? data, }) { - final _result = create(); + final $result = create(); if (serviceUuid != null) { - _result.serviceUuid = serviceUuid; + $result.serviceUuid = serviceUuid; } if (data != null) { - _result.data = data; + $result.data = data; } - return _result; + return $result; } + ServiceDataEntry._() : super(); factory ServiceDataEntry.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory ServiceDataEntry.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ServiceDataEntry', createEmptyInstance: create) + ..aOM(1, _omitFieldNames ? '' : 'serviceUuid', protoName: 'serviceUuid', subBuilder: Uuid.create) + ..a<$core.List<$core.int>>(2, _omitFieldNames ? '' : 'data', $pb.PbFieldType.OY) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -1314,8 +1606,10 @@ class ServiceDataEntry extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - ServiceDataEntry copyWith(void Function(ServiceDataEntry) updates) => super.copyWith((message) => updates(message as ServiceDataEntry)) as ServiceDataEntry; // ignore: deprecated_member_use + ServiceDataEntry copyWith(void Function(ServiceDataEntry) updates) => super.copyWith((message) => updates(message as ServiceDataEntry)) as ServiceDataEntry; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static ServiceDataEntry create() => ServiceDataEntry._(); ServiceDataEntry createEmptyInstance() => create(); @@ -1346,23 +1640,24 @@ class ServiceDataEntry extends $pb.GeneratedMessage { } class ServicesWithCharacteristics extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ServicesWithCharacteristics', createEmptyInstance: create) - ..pc(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'items', $pb.PbFieldType.PM, subBuilder: ServiceWithCharacteristics.create) - ..hasRequiredFields = false - ; - - ServicesWithCharacteristics._() : super(); factory ServicesWithCharacteristics({ $core.Iterable? items, }) { - final _result = create(); + final $result = create(); if (items != null) { - _result.items.addAll(items); + $result.items.addAll(items); } - return _result; + return $result; } + ServicesWithCharacteristics._() : super(); factory ServicesWithCharacteristics.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory ServicesWithCharacteristics.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ServicesWithCharacteristics', createEmptyInstance: create) + ..pc(1, _omitFieldNames ? '' : 'items', $pb.PbFieldType.PM, subBuilder: ServiceWithCharacteristics.create) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -1372,8 +1667,10 @@ class ServicesWithCharacteristics extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - ServicesWithCharacteristics copyWith(void Function(ServicesWithCharacteristics) updates) => super.copyWith((message) => updates(message as ServicesWithCharacteristics)) as ServicesWithCharacteristics; // ignore: deprecated_member_use + ServicesWithCharacteristics copyWith(void Function(ServicesWithCharacteristics) updates) => super.copyWith((message) => updates(message as ServicesWithCharacteristics)) as ServicesWithCharacteristics; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static ServicesWithCharacteristics create() => ServicesWithCharacteristics._(); ServicesWithCharacteristics createEmptyInstance() => create(); @@ -1387,28 +1684,29 @@ class ServicesWithCharacteristics extends $pb.GeneratedMessage { } class ServiceWithCharacteristics extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ServiceWithCharacteristics', createEmptyInstance: create) - ..aOM(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'serviceId', protoName: 'serviceId', subBuilder: Uuid.create) - ..pc(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'characteristics', $pb.PbFieldType.PM, subBuilder: Uuid.create) - ..hasRequiredFields = false - ; - - ServiceWithCharacteristics._() : super(); factory ServiceWithCharacteristics({ Uuid? serviceId, $core.Iterable? characteristics, }) { - final _result = create(); + final $result = create(); if (serviceId != null) { - _result.serviceId = serviceId; + $result.serviceId = serviceId; } if (characteristics != null) { - _result.characteristics.addAll(characteristics); + $result.characteristics.addAll(characteristics); } - return _result; + return $result; } + ServiceWithCharacteristics._() : super(); factory ServiceWithCharacteristics.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory ServiceWithCharacteristics.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ServiceWithCharacteristics', createEmptyInstance: create) + ..aOM(1, _omitFieldNames ? '' : 'serviceId', protoName: 'serviceId', subBuilder: Uuid.create) + ..pc(2, _omitFieldNames ? '' : 'characteristics', $pb.PbFieldType.PM, subBuilder: Uuid.create) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -1418,8 +1716,10 @@ class ServiceWithCharacteristics extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - ServiceWithCharacteristics copyWith(void Function(ServiceWithCharacteristics) updates) => super.copyWith((message) => updates(message as ServiceWithCharacteristics)) as ServiceWithCharacteristics; // ignore: deprecated_member_use + ServiceWithCharacteristics copyWith(void Function(ServiceWithCharacteristics) updates) => super.copyWith((message) => updates(message as ServiceWithCharacteristics)) as ServiceWithCharacteristics; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static ServiceWithCharacteristics create() => ServiceWithCharacteristics._(); ServiceWithCharacteristics createEmptyInstance() => create(); @@ -1444,23 +1744,24 @@ class ServiceWithCharacteristics extends $pb.GeneratedMessage { } class DiscoverServicesRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'DiscoverServicesRequest', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceId', protoName: 'deviceId') - ..hasRequiredFields = false - ; - - DiscoverServicesRequest._() : super(); factory DiscoverServicesRequest({ $core.String? deviceId, }) { - final _result = create(); + final $result = create(); if (deviceId != null) { - _result.deviceId = deviceId; + $result.deviceId = deviceId; } - return _result; + return $result; } + DiscoverServicesRequest._() : super(); factory DiscoverServicesRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory DiscoverServicesRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'DiscoverServicesRequest', createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'deviceId', protoName: 'deviceId') + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -1470,8 +1771,10 @@ class DiscoverServicesRequest extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - DiscoverServicesRequest copyWith(void Function(DiscoverServicesRequest) updates) => super.copyWith((message) => updates(message as DiscoverServicesRequest)) as DiscoverServicesRequest; // ignore: deprecated_member_use + DiscoverServicesRequest copyWith(void Function(DiscoverServicesRequest) updates) => super.copyWith((message) => updates(message as DiscoverServicesRequest)) as DiscoverServicesRequest; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static DiscoverServicesRequest create() => DiscoverServicesRequest._(); DiscoverServicesRequest createEmptyInstance() => create(); @@ -1491,28 +1794,29 @@ class DiscoverServicesRequest extends $pb.GeneratedMessage { } class DiscoverServicesInfo extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'DiscoverServicesInfo', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceId', protoName: 'deviceId') - ..pc(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'services', $pb.PbFieldType.PM, subBuilder: DiscoveredService.create) - ..hasRequiredFields = false - ; - - DiscoverServicesInfo._() : super(); factory DiscoverServicesInfo({ $core.String? deviceId, $core.Iterable? services, }) { - final _result = create(); + final $result = create(); if (deviceId != null) { - _result.deviceId = deviceId; + $result.deviceId = deviceId; } if (services != null) { - _result.services.addAll(services); + $result.services.addAll(services); } - return _result; + return $result; } + DiscoverServicesInfo._() : super(); factory DiscoverServicesInfo.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory DiscoverServicesInfo.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'DiscoverServicesInfo', createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'deviceId', protoName: 'deviceId') + ..pc(2, _omitFieldNames ? '' : 'services', $pb.PbFieldType.PM, subBuilder: DiscoveredService.create) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -1522,8 +1826,10 @@ class DiscoverServicesInfo extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - DiscoverServicesInfo copyWith(void Function(DiscoverServicesInfo) updates) => super.copyWith((message) => updates(message as DiscoverServicesInfo)) as DiscoverServicesInfo; // ignore: deprecated_member_use + DiscoverServicesInfo copyWith(void Function(DiscoverServicesInfo) updates) => super.copyWith((message) => updates(message as DiscoverServicesInfo)) as DiscoverServicesInfo; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static DiscoverServicesInfo create() => DiscoverServicesInfo._(); DiscoverServicesInfo createEmptyInstance() => create(); @@ -1546,16 +1852,6 @@ class DiscoverServicesInfo extends $pb.GeneratedMessage { } class DiscoveredService extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'DiscoveredService', createEmptyInstance: create) - ..aOM(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'serviceUuid', protoName: 'serviceUuid', subBuilder: Uuid.create) - ..pc(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'characteristicUuids', $pb.PbFieldType.PM, protoName: 'characteristicUuids', subBuilder: Uuid.create) - ..pc(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'includedServices', $pb.PbFieldType.PM, protoName: 'includedServices', subBuilder: DiscoveredService.create) - ..pc(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'characteristics', $pb.PbFieldType.PM, subBuilder: DiscoveredCharacteristic.create) - ..aOS(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'serviceInstanceId', protoName: 'serviceInstanceId') - ..hasRequiredFields = false - ; - - DiscoveredService._() : super(); factory DiscoveredService({ Uuid? serviceUuid, $core.Iterable? characteristicUuids, @@ -1563,26 +1859,37 @@ class DiscoveredService extends $pb.GeneratedMessage { $core.Iterable? characteristics, $core.String? serviceInstanceId, }) { - final _result = create(); + final $result = create(); if (serviceUuid != null) { - _result.serviceUuid = serviceUuid; + $result.serviceUuid = serviceUuid; } if (characteristicUuids != null) { - _result.characteristicUuids.addAll(characteristicUuids); + $result.characteristicUuids.addAll(characteristicUuids); } if (includedServices != null) { - _result.includedServices.addAll(includedServices); + $result.includedServices.addAll(includedServices); } if (characteristics != null) { - _result.characteristics.addAll(characteristics); + $result.characteristics.addAll(characteristics); } if (serviceInstanceId != null) { - _result.serviceInstanceId = serviceInstanceId; + $result.serviceInstanceId = serviceInstanceId; } - return _result; + return $result; } + DiscoveredService._() : super(); factory DiscoveredService.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory DiscoveredService.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'DiscoveredService', createEmptyInstance: create) + ..aOM(1, _omitFieldNames ? '' : 'serviceUuid', protoName: 'serviceUuid', subBuilder: Uuid.create) + ..pc(2, _omitFieldNames ? '' : 'characteristicUuids', $pb.PbFieldType.PM, protoName: 'characteristicUuids', subBuilder: Uuid.create) + ..pc(3, _omitFieldNames ? '' : 'includedServices', $pb.PbFieldType.PM, protoName: 'includedServices', subBuilder: DiscoveredService.create) + ..pc(4, _omitFieldNames ? '' : 'characteristics', $pb.PbFieldType.PM, subBuilder: DiscoveredCharacteristic.create) + ..aOS(5, _omitFieldNames ? '' : 'serviceInstanceId', protoName: 'serviceInstanceId') + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -1592,8 +1899,10 @@ class DiscoveredService extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - DiscoveredService copyWith(void Function(DiscoveredService) updates) => super.copyWith((message) => updates(message as DiscoveredService)) as DiscoveredService; // ignore: deprecated_member_use + DiscoveredService copyWith(void Function(DiscoveredService) updates) => super.copyWith((message) => updates(message as DiscoveredService)) as DiscoveredService; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static DiscoveredService create() => DiscoveredService._(); DiscoveredService createEmptyInstance() => create(); @@ -1633,19 +1942,6 @@ class DiscoveredService extends $pb.GeneratedMessage { } class DiscoveredCharacteristic extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'DiscoveredCharacteristic', createEmptyInstance: create) - ..aOM(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'characteristicId', protoName: 'characteristicId', subBuilder: Uuid.create) - ..aOM(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'serviceId', protoName: 'serviceId', subBuilder: Uuid.create) - ..aOB(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'isReadable', protoName: 'isReadable') - ..aOB(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'isWritableWithResponse', protoName: 'isWritableWithResponse') - ..aOB(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'isWritableWithoutResponse', protoName: 'isWritableWithoutResponse') - ..aOB(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'isNotifiable', protoName: 'isNotifiable') - ..aOB(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'isIndicatable', protoName: 'isIndicatable') - ..aOS(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'characteristicInstanceId', protoName: 'characteristicInstanceId') - ..hasRequiredFields = false - ; - - DiscoveredCharacteristic._() : super(); factory DiscoveredCharacteristic({ Uuid? characteristicId, Uuid? serviceId, @@ -1656,35 +1952,49 @@ class DiscoveredCharacteristic extends $pb.GeneratedMessage { $core.bool? isIndicatable, $core.String? characteristicInstanceId, }) { - final _result = create(); + final $result = create(); if (characteristicId != null) { - _result.characteristicId = characteristicId; + $result.characteristicId = characteristicId; } if (serviceId != null) { - _result.serviceId = serviceId; + $result.serviceId = serviceId; } if (isReadable != null) { - _result.isReadable = isReadable; + $result.isReadable = isReadable; } if (isWritableWithResponse != null) { - _result.isWritableWithResponse = isWritableWithResponse; + $result.isWritableWithResponse = isWritableWithResponse; } if (isWritableWithoutResponse != null) { - _result.isWritableWithoutResponse = isWritableWithoutResponse; + $result.isWritableWithoutResponse = isWritableWithoutResponse; } if (isNotifiable != null) { - _result.isNotifiable = isNotifiable; + $result.isNotifiable = isNotifiable; } if (isIndicatable != null) { - _result.isIndicatable = isIndicatable; + $result.isIndicatable = isIndicatable; } if (characteristicInstanceId != null) { - _result.characteristicInstanceId = characteristicInstanceId; + $result.characteristicInstanceId = characteristicInstanceId; } - return _result; + return $result; } + DiscoveredCharacteristic._() : super(); factory DiscoveredCharacteristic.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory DiscoveredCharacteristic.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'DiscoveredCharacteristic', createEmptyInstance: create) + ..aOM(1, _omitFieldNames ? '' : 'characteristicId', protoName: 'characteristicId', subBuilder: Uuid.create) + ..aOM(2, _omitFieldNames ? '' : 'serviceId', protoName: 'serviceId', subBuilder: Uuid.create) + ..aOB(3, _omitFieldNames ? '' : 'isReadable', protoName: 'isReadable') + ..aOB(4, _omitFieldNames ? '' : 'isWritableWithResponse', protoName: 'isWritableWithResponse') + ..aOB(5, _omitFieldNames ? '' : 'isWritableWithoutResponse', protoName: 'isWritableWithoutResponse') + ..aOB(6, _omitFieldNames ? '' : 'isNotifiable', protoName: 'isNotifiable') + ..aOB(7, _omitFieldNames ? '' : 'isIndicatable', protoName: 'isIndicatable') + ..aOS(8, _omitFieldNames ? '' : 'characteristicInstanceId', protoName: 'characteristicInstanceId') + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -1694,8 +2004,10 @@ class DiscoveredCharacteristic extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - DiscoveredCharacteristic copyWith(void Function(DiscoveredCharacteristic) updates) => super.copyWith((message) => updates(message as DiscoveredCharacteristic)) as DiscoveredCharacteristic; // ignore: deprecated_member_use + DiscoveredCharacteristic copyWith(void Function(DiscoveredCharacteristic) updates) => super.copyWith((message) => updates(message as DiscoveredCharacteristic)) as DiscoveredCharacteristic; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static DiscoveredCharacteristic create() => DiscoveredCharacteristic._(); DiscoveredCharacteristic createEmptyInstance() => create(); @@ -1782,23 +2094,24 @@ class DiscoveredCharacteristic extends $pb.GeneratedMessage { } class ReadRssiRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ReadRssiRequest', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deviceId', protoName: 'deviceId') - ..hasRequiredFields = false - ; - - ReadRssiRequest._() : super(); factory ReadRssiRequest({ $core.String? deviceId, }) { - final _result = create(); + final $result = create(); if (deviceId != null) { - _result.deviceId = deviceId; + $result.deviceId = deviceId; } - return _result; + return $result; } + ReadRssiRequest._() : super(); factory ReadRssiRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory ReadRssiRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ReadRssiRequest', createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'deviceId', protoName: 'deviceId') + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -1808,8 +2121,10 @@ class ReadRssiRequest extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - ReadRssiRequest copyWith(void Function(ReadRssiRequest) updates) => super.copyWith((message) => updates(message as ReadRssiRequest)) as ReadRssiRequest; // ignore: deprecated_member_use + ReadRssiRequest copyWith(void Function(ReadRssiRequest) updates) => super.copyWith((message) => updates(message as ReadRssiRequest)) as ReadRssiRequest; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static ReadRssiRequest create() => ReadRssiRequest._(); ReadRssiRequest createEmptyInstance() => create(); @@ -1829,23 +2144,24 @@ class ReadRssiRequest extends $pb.GeneratedMessage { } class ReadRssiResult extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ReadRssiResult', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'rssi', $pb.PbFieldType.O3) - ..hasRequiredFields = false - ; - - ReadRssiResult._() : super(); factory ReadRssiResult({ $core.int? rssi, }) { - final _result = create(); + final $result = create(); if (rssi != null) { - _result.rssi = rssi; + $result.rssi = rssi; } - return _result; + return $result; } + ReadRssiResult._() : super(); factory ReadRssiResult.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory ReadRssiResult.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'ReadRssiResult', createEmptyInstance: create) + ..a<$core.int>(1, _omitFieldNames ? '' : 'rssi', $pb.PbFieldType.O3) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -1855,8 +2171,10 @@ class ReadRssiResult extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - ReadRssiResult copyWith(void Function(ReadRssiResult) updates) => super.copyWith((message) => updates(message as ReadRssiResult)) as ReadRssiResult; // ignore: deprecated_member_use + ReadRssiResult copyWith(void Function(ReadRssiResult) updates) => super.copyWith((message) => updates(message as ReadRssiResult)) as ReadRssiResult; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static ReadRssiResult create() => ReadRssiResult._(); ReadRssiResult createEmptyInstance() => create(); @@ -1875,24 +2193,69 @@ class ReadRssiResult extends $pb.GeneratedMessage { void clearRssi() => clearField(1); } -class Uuid extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'Uuid', createEmptyInstance: create) - ..a<$core.List<$core.int>>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'data', $pb.PbFieldType.OY) +class DeviceInfoCollection extends $pb.GeneratedMessage { + factory DeviceInfoCollection({ + $core.Iterable? devices, + }) { + final $result = create(); + if (devices != null) { + $result.devices.addAll(devices); + } + return $result; + } + DeviceInfoCollection._() : super(); + factory DeviceInfoCollection.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory DeviceInfoCollection.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'DeviceInfoCollection', createEmptyInstance: create) + ..pc(1, _omitFieldNames ? '' : 'devices', $pb.PbFieldType.PM, subBuilder: DeviceInfo.create) ..hasRequiredFields = false ; - Uuid._() : super(); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + DeviceInfoCollection clone() => DeviceInfoCollection()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + DeviceInfoCollection copyWith(void Function(DeviceInfoCollection) updates) => super.copyWith((message) => updates(message as DeviceInfoCollection)) as DeviceInfoCollection; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static DeviceInfoCollection create() => DeviceInfoCollection._(); + DeviceInfoCollection createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static DeviceInfoCollection getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static DeviceInfoCollection? _defaultInstance; + + @$pb.TagNumber(1) + $core.List get devices => $_getList(0); +} + +class Uuid extends $pb.GeneratedMessage { factory Uuid({ $core.List<$core.int>? data, }) { - final _result = create(); + final $result = create(); if (data != null) { - _result.data = data; + $result.data = data; } - return _result; + return $result; } + Uuid._() : super(); factory Uuid.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory Uuid.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'Uuid', createEmptyInstance: create) + ..a<$core.List<$core.int>>(1, _omitFieldNames ? '' : 'data', $pb.PbFieldType.OY) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -1902,8 +2265,10 @@ class Uuid extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - Uuid copyWith(void Function(Uuid) updates) => super.copyWith((message) => updates(message as Uuid)) as Uuid; // ignore: deprecated_member_use + Uuid copyWith(void Function(Uuid) updates) => super.copyWith((message) => updates(message as Uuid)) as Uuid; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static Uuid create() => Uuid._(); Uuid createEmptyInstance() => create(); @@ -1923,28 +2288,29 @@ class Uuid extends $pb.GeneratedMessage { } class GenericFailure extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GenericFailure', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'code', $pb.PbFieldType.O3) - ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'message') - ..hasRequiredFields = false - ; - - GenericFailure._() : super(); factory GenericFailure({ $core.int? code, $core.String? message, }) { - final _result = create(); + final $result = create(); if (code != null) { - _result.code = code; + $result.code = code; } if (message != null) { - _result.message = message; + $result.message = message; } - return _result; + return $result; } + GenericFailure._() : super(); factory GenericFailure.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory GenericFailure.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'GenericFailure', createEmptyInstance: create) + ..a<$core.int>(1, _omitFieldNames ? '' : 'code', $pb.PbFieldType.O3) + ..aOS(2, _omitFieldNames ? '' : 'message') + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -1954,8 +2320,10 @@ class GenericFailure extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - GenericFailure copyWith(void Function(GenericFailure) updates) => super.copyWith((message) => updates(message as GenericFailure)) as GenericFailure; // ignore: deprecated_member_use + GenericFailure copyWith(void Function(GenericFailure) updates) => super.copyWith((message) => updates(message as GenericFailure)) as GenericFailure; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static GenericFailure create() => GenericFailure._(); GenericFailure createEmptyInstance() => create(); @@ -1984,23 +2352,24 @@ class GenericFailure extends $pb.GeneratedMessage { } class IsConnectable extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'IsConnectable', createEmptyInstance: create) - ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'code', $pb.PbFieldType.O3) - ..hasRequiredFields = false - ; - - IsConnectable._() : super(); factory IsConnectable({ $core.int? code, }) { - final _result = create(); + final $result = create(); if (code != null) { - _result.code = code; + $result.code = code; } - return _result; + return $result; } + IsConnectable._() : super(); factory IsConnectable.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory IsConnectable.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'IsConnectable', createEmptyInstance: create) + ..a<$core.int>(1, _omitFieldNames ? '' : 'code', $pb.PbFieldType.O3) + ..hasRequiredFields = false + ; + @$core.Deprecated( 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' @@ -2010,8 +2379,10 @@ class IsConnectable extends $pb.GeneratedMessage { 'Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') - IsConnectable copyWith(void Function(IsConnectable) updates) => super.copyWith((message) => updates(message as IsConnectable)) as IsConnectable; // ignore: deprecated_member_use + IsConnectable copyWith(void Function(IsConnectable) updates) => super.copyWith((message) => updates(message as IsConnectable)) as IsConnectable; + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static IsConnectable create() => IsConnectable._(); IsConnectable createEmptyInstance() => create(); @@ -2030,3 +2401,6 @@ class IsConnectable extends $pb.GeneratedMessage { void clearCode() => clearField(1); } + +const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names'); +const _omitMessageNames = $core.bool.fromEnvironment('protobuf.omit_message_names'); diff --git a/packages/reactive_ble_mobile/lib/src/generated/bledata.pbenum.dart b/packages/reactive_ble_mobile/lib/src/generated/bledata.pbenum.dart index 1ccca4dd..10ab46c7 100644 --- a/packages/reactive_ble_mobile/lib/src/generated/bledata.pbenum.dart +++ b/packages/reactive_ble_mobile/lib/src/generated/bledata.pbenum.dart @@ -1,7 +1,11 @@ -/// +// // Generated code. Do not modify. // source: bledata.proto // // @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import diff --git a/packages/reactive_ble_mobile/lib/src/generated/bledata.pbjson.dart b/packages/reactive_ble_mobile/lib/src/generated/bledata.pbjson.dart index aaa1515f..e9b83aaf 100644 --- a/packages/reactive_ble_mobile/lib/src/generated/bledata.pbjson.dart +++ b/packages/reactive_ble_mobile/lib/src/generated/bledata.pbjson.dart @@ -1,361 +1,548 @@ -/// +// // Generated code. Do not modify. // source: bledata.proto // // @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,deprecated_member_use_from_same_package,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name -import 'dart:core' as $core; +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import + import 'dart:convert' as $convert; +import 'dart:core' as $core; import 'dart:typed_data' as $typed_data; + +@$core.Deprecated('Use initializationRequestDescriptor instead') +const InitializationRequest$json = { + '1': 'InitializationRequest', + '2': [ + {'1': 'restorationKey', '3': 1, '4': 1, '5': 9, '10': 'restorationKey'}, + ], +}; + +/// Descriptor for `InitializationRequest`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List initializationRequestDescriptor = $convert.base64Decode( + 'ChVJbml0aWFsaXphdGlvblJlcXVlc3QSJgoOcmVzdG9yYXRpb25LZXkYASABKAlSDnJlc3Rvcm' + 'F0aW9uS2V5'); + @$core.Deprecated('Use scanForDevicesRequestDescriptor instead') -const ScanForDevicesRequest$json = const { +const ScanForDevicesRequest$json = { '1': 'ScanForDevicesRequest', - '2': const [ - const {'1': 'serviceUuids', '3': 1, '4': 3, '5': 11, '6': '.Uuid', '10': 'serviceUuids'}, - const {'1': 'scanMode', '3': 2, '4': 1, '5': 5, '10': 'scanMode'}, - const {'1': 'requireLocationServicesEnabled', '3': 3, '4': 1, '5': 8, '10': 'requireLocationServicesEnabled'}, + '2': [ + {'1': 'serviceUuids', '3': 1, '4': 3, '5': 11, '6': '.Uuid', '10': 'serviceUuids'}, + {'1': 'scanMode', '3': 2, '4': 1, '5': 5, '10': 'scanMode'}, + {'1': 'requireLocationServicesEnabled', '3': 3, '4': 1, '5': 8, '10': 'requireLocationServicesEnabled'}, ], }; /// Descriptor for `ScanForDevicesRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List scanForDevicesRequestDescriptor = $convert.base64Decode('ChVTY2FuRm9yRGV2aWNlc1JlcXVlc3QSKQoMc2VydmljZVV1aWRzGAEgAygLMgUuVXVpZFIMc2VydmljZVV1aWRzEhoKCHNjYW5Nb2RlGAIgASgFUghzY2FuTW9kZRJGCh5yZXF1aXJlTG9jYXRpb25TZXJ2aWNlc0VuYWJsZWQYAyABKAhSHnJlcXVpcmVMb2NhdGlvblNlcnZpY2VzRW5hYmxlZA=='); +final $typed_data.Uint8List scanForDevicesRequestDescriptor = $convert.base64Decode( + 'ChVTY2FuRm9yRGV2aWNlc1JlcXVlc3QSKQoMc2VydmljZVV1aWRzGAEgAygLMgUuVXVpZFIMc2' + 'VydmljZVV1aWRzEhoKCHNjYW5Nb2RlGAIgASgFUghzY2FuTW9kZRJGCh5yZXF1aXJlTG9jYXRp' + 'b25TZXJ2aWNlc0VuYWJsZWQYAyABKAhSHnJlcXVpcmVMb2NhdGlvblNlcnZpY2VzRW5hYmxlZA' + '=='); + @$core.Deprecated('Use deviceScanInfoDescriptor instead') -const DeviceScanInfo$json = const { +const DeviceScanInfo$json = { '1': 'DeviceScanInfo', - '2': const [ - const {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'}, - const {'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'}, - const {'1': 'failure', '3': 3, '4': 1, '5': 11, '6': '.GenericFailure', '10': 'failure'}, - const {'1': 'serviceData', '3': 4, '4': 3, '5': 11, '6': '.ServiceDataEntry', '10': 'serviceData'}, - const {'1': 'manufacturerData', '3': 6, '4': 1, '5': 12, '10': 'manufacturerData'}, - const {'1': 'serviceUuids', '3': 7, '4': 3, '5': 11, '6': '.Uuid', '10': 'serviceUuids'}, - const {'1': 'rssi', '3': 5, '4': 1, '5': 5, '10': 'rssi'}, - const {'1': 'isConnectable', '3': 8, '4': 1, '5': 11, '6': '.IsConnectable', '10': 'isConnectable'}, + '2': [ + {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'}, + {'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'}, + {'1': 'failure', '3': 3, '4': 1, '5': 11, '6': '.GenericFailure', '10': 'failure'}, + {'1': 'serviceData', '3': 4, '4': 3, '5': 11, '6': '.ServiceDataEntry', '10': 'serviceData'}, + {'1': 'manufacturerData', '3': 6, '4': 1, '5': 12, '10': 'manufacturerData'}, + {'1': 'serviceUuids', '3': 7, '4': 3, '5': 11, '6': '.Uuid', '10': 'serviceUuids'}, + {'1': 'rssi', '3': 5, '4': 1, '5': 5, '10': 'rssi'}, + {'1': 'isConnectable', '3': 8, '4': 1, '5': 11, '6': '.IsConnectable', '10': 'isConnectable'}, ], }; /// Descriptor for `DeviceScanInfo`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List deviceScanInfoDescriptor = $convert.base64Decode('Cg5EZXZpY2VTY2FuSW5mbxIOCgJpZBgBIAEoCVICaWQSEgoEbmFtZRgCIAEoCVIEbmFtZRIpCgdmYWlsdXJlGAMgASgLMg8uR2VuZXJpY0ZhaWx1cmVSB2ZhaWx1cmUSMwoLc2VydmljZURhdGEYBCADKAsyES5TZXJ2aWNlRGF0YUVudHJ5UgtzZXJ2aWNlRGF0YRIqChBtYW51ZmFjdHVyZXJEYXRhGAYgASgMUhBtYW51ZmFjdHVyZXJEYXRhEikKDHNlcnZpY2VVdWlkcxgHIAMoCzIFLlV1aWRSDHNlcnZpY2VVdWlkcxISCgRyc3NpGAUgASgFUgRyc3NpEjQKDWlzQ29ubmVjdGFibGUYCCABKAsyDi5Jc0Nvbm5lY3RhYmxlUg1pc0Nvbm5lY3RhYmxl'); +final $typed_data.Uint8List deviceScanInfoDescriptor = $convert.base64Decode( + 'Cg5EZXZpY2VTY2FuSW5mbxIOCgJpZBgBIAEoCVICaWQSEgoEbmFtZRgCIAEoCVIEbmFtZRIpCg' + 'dmYWlsdXJlGAMgASgLMg8uR2VuZXJpY0ZhaWx1cmVSB2ZhaWx1cmUSMwoLc2VydmljZURhdGEY' + 'BCADKAsyES5TZXJ2aWNlRGF0YUVudHJ5UgtzZXJ2aWNlRGF0YRIqChBtYW51ZmFjdHVyZXJEYX' + 'RhGAYgASgMUhBtYW51ZmFjdHVyZXJEYXRhEikKDHNlcnZpY2VVdWlkcxgHIAMoCzIFLlV1aWRS' + 'DHNlcnZpY2VVdWlkcxISCgRyc3NpGAUgASgFUgRyc3NpEjQKDWlzQ29ubmVjdGFibGUYCCABKA' + 'syDi5Jc0Nvbm5lY3RhYmxlUg1pc0Nvbm5lY3RhYmxl'); + @$core.Deprecated('Use connectToDeviceRequestDescriptor instead') -const ConnectToDeviceRequest$json = const { +const ConnectToDeviceRequest$json = { '1': 'ConnectToDeviceRequest', - '2': const [ - const {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, - const {'1': 'servicesWithCharacteristicsToDiscover', '3': 2, '4': 1, '5': 11, '6': '.ServicesWithCharacteristics', '10': 'servicesWithCharacteristicsToDiscover'}, - const {'1': 'timeoutInMs', '3': 3, '4': 1, '5': 5, '10': 'timeoutInMs'}, + '2': [ + {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, + {'1': 'servicesWithCharacteristicsToDiscover', '3': 2, '4': 1, '5': 11, '6': '.ServicesWithCharacteristics', '10': 'servicesWithCharacteristicsToDiscover'}, + {'1': 'timeoutInMs', '3': 3, '4': 1, '5': 5, '10': 'timeoutInMs'}, ], }; /// Descriptor for `ConnectToDeviceRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List connectToDeviceRequestDescriptor = $convert.base64Decode('ChZDb25uZWN0VG9EZXZpY2VSZXF1ZXN0EhoKCGRldmljZUlkGAEgASgJUghkZXZpY2VJZBJyCiVzZXJ2aWNlc1dpdGhDaGFyYWN0ZXJpc3RpY3NUb0Rpc2NvdmVyGAIgASgLMhwuU2VydmljZXNXaXRoQ2hhcmFjdGVyaXN0aWNzUiVzZXJ2aWNlc1dpdGhDaGFyYWN0ZXJpc3RpY3NUb0Rpc2NvdmVyEiAKC3RpbWVvdXRJbk1zGAMgASgFUgt0aW1lb3V0SW5Ncw=='); +final $typed_data.Uint8List connectToDeviceRequestDescriptor = $convert.base64Decode( + 'ChZDb25uZWN0VG9EZXZpY2VSZXF1ZXN0EhoKCGRldmljZUlkGAEgASgJUghkZXZpY2VJZBJyCi' + 'VzZXJ2aWNlc1dpdGhDaGFyYWN0ZXJpc3RpY3NUb0Rpc2NvdmVyGAIgASgLMhwuU2VydmljZXNX' + 'aXRoQ2hhcmFjdGVyaXN0aWNzUiVzZXJ2aWNlc1dpdGhDaGFyYWN0ZXJpc3RpY3NUb0Rpc2Nvdm' + 'VyEiAKC3RpbWVvdXRJbk1zGAMgASgFUgt0aW1lb3V0SW5Ncw=='); + +@$core.Deprecated('Use bondInfoDescriptor instead') +const BondInfo$json = { + '1': 'BondInfo', + '2': [ + {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'}, + {'1': 'bondState', '3': 2, '4': 1, '5': 5, '10': 'bondState'}, + ], +}; + +/// Descriptor for `BondInfo`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List bondInfoDescriptor = $convert.base64Decode( + 'CghCb25kSW5mbxIOCgJpZBgBIAEoCVICaWQSHAoJYm9uZFN0YXRlGAIgASgFUglib25kU3RhdG' + 'U='); + @$core.Deprecated('Use deviceInfoDescriptor instead') -const DeviceInfo$json = const { +const DeviceInfo$json = { '1': 'DeviceInfo', - '2': const [ - const {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'}, - const {'1': 'connectionState', '3': 2, '4': 1, '5': 5, '10': 'connectionState'}, - const {'1': 'failure', '3': 3, '4': 1, '5': 11, '6': '.GenericFailure', '10': 'failure'}, + '2': [ + {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'}, + {'1': 'connectionState', '3': 2, '4': 1, '5': 5, '10': 'connectionState'}, + {'1': 'failure', '3': 3, '4': 1, '5': 11, '6': '.GenericFailure', '10': 'failure'}, ], }; /// Descriptor for `DeviceInfo`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List deviceInfoDescriptor = $convert.base64Decode('CgpEZXZpY2VJbmZvEg4KAmlkGAEgASgJUgJpZBIoCg9jb25uZWN0aW9uU3RhdGUYAiABKAVSD2Nvbm5lY3Rpb25TdGF0ZRIpCgdmYWlsdXJlGAMgASgLMg8uR2VuZXJpY0ZhaWx1cmVSB2ZhaWx1cmU='); +final $typed_data.Uint8List deviceInfoDescriptor = $convert.base64Decode( + 'CgpEZXZpY2VJbmZvEg4KAmlkGAEgASgJUgJpZBIoCg9jb25uZWN0aW9uU3RhdGUYAiABKAVSD2' + 'Nvbm5lY3Rpb25TdGF0ZRIpCgdmYWlsdXJlGAMgASgLMg8uR2VuZXJpY0ZhaWx1cmVSB2ZhaWx1' + 'cmU='); + +@$core.Deprecated('Use restoredDeviceInfoDescriptor instead') +const RestoredDeviceInfo$json = { + '1': 'RestoredDeviceInfo', + '2': [ + {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'}, + {'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'}, + {'1': 'subscriptions', '3': 3, '4': 3, '5': 11, '6': '.CharacteristicAddress', '10': 'subscriptions'}, + ], +}; + +/// Descriptor for `RestoredDeviceInfo`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List restoredDeviceInfoDescriptor = $convert.base64Decode( + 'ChJSZXN0b3JlZERldmljZUluZm8SDgoCaWQYASABKAlSAmlkEhIKBG5hbWUYAiABKAlSBG5hbW' + 'USPAoNc3Vic2NyaXB0aW9ucxgDIAMoCzIWLkNoYXJhY3RlcmlzdGljQWRkcmVzc1INc3Vic2Ny' + 'aXB0aW9ucw=='); + +@$core.Deprecated('Use restoredDeviceInfoCollectionDescriptor instead') +const RestoredDeviceInfoCollection$json = { + '1': 'RestoredDeviceInfoCollection', + '2': [ + {'1': 'devices', '3': 1, '4': 3, '5': 11, '6': '.RestoredDeviceInfo', '10': 'devices'}, + ], +}; + +/// Descriptor for `RestoredDeviceInfoCollection`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List restoredDeviceInfoCollectionDescriptor = $convert.base64Decode( + 'ChxSZXN0b3JlZERldmljZUluZm9Db2xsZWN0aW9uEi0KB2RldmljZXMYASADKAsyEy5SZXN0b3' + 'JlZERldmljZUluZm9SB2RldmljZXM='); + @$core.Deprecated('Use disconnectFromDeviceRequestDescriptor instead') -const DisconnectFromDeviceRequest$json = const { +const DisconnectFromDeviceRequest$json = { '1': 'DisconnectFromDeviceRequest', - '2': const [ - const {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, + '2': [ + {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, ], }; /// Descriptor for `DisconnectFromDeviceRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List disconnectFromDeviceRequestDescriptor = $convert.base64Decode('ChtEaXNjb25uZWN0RnJvbURldmljZVJlcXVlc3QSGgoIZGV2aWNlSWQYASABKAlSCGRldmljZUlk'); +final $typed_data.Uint8List disconnectFromDeviceRequestDescriptor = $convert.base64Decode( + 'ChtEaXNjb25uZWN0RnJvbURldmljZVJlcXVlc3QSGgoIZGV2aWNlSWQYASABKAlSCGRldmljZU' + 'lk'); + @$core.Deprecated('Use clearGattCacheRequestDescriptor instead') -const ClearGattCacheRequest$json = const { +const ClearGattCacheRequest$json = { '1': 'ClearGattCacheRequest', - '2': const [ - const {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, + '2': [ + {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, ], }; /// Descriptor for `ClearGattCacheRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List clearGattCacheRequestDescriptor = $convert.base64Decode('ChVDbGVhckdhdHRDYWNoZVJlcXVlc3QSGgoIZGV2aWNlSWQYASABKAlSCGRldmljZUlk'); +final $typed_data.Uint8List clearGattCacheRequestDescriptor = $convert.base64Decode( + 'ChVDbGVhckdhdHRDYWNoZVJlcXVlc3QSGgoIZGV2aWNlSWQYASABKAlSCGRldmljZUlk'); + @$core.Deprecated('Use clearGattCacheInfoDescriptor instead') -const ClearGattCacheInfo$json = const { +const ClearGattCacheInfo$json = { '1': 'ClearGattCacheInfo', - '2': const [ - const {'1': 'failure', '3': 1, '4': 1, '5': 11, '6': '.GenericFailure', '10': 'failure'}, + '2': [ + {'1': 'failure', '3': 1, '4': 1, '5': 11, '6': '.GenericFailure', '10': 'failure'}, ], }; /// Descriptor for `ClearGattCacheInfo`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List clearGattCacheInfoDescriptor = $convert.base64Decode('ChJDbGVhckdhdHRDYWNoZUluZm8SKQoHZmFpbHVyZRgBIAEoCzIPLkdlbmVyaWNGYWlsdXJlUgdmYWlsdXJl'); +final $typed_data.Uint8List clearGattCacheInfoDescriptor = $convert.base64Decode( + 'ChJDbGVhckdhdHRDYWNoZUluZm8SKQoHZmFpbHVyZRgBIAEoCzIPLkdlbmVyaWNGYWlsdXJlUg' + 'dmYWlsdXJl'); + @$core.Deprecated('Use notifyCharacteristicRequestDescriptor instead') -const NotifyCharacteristicRequest$json = const { +const NotifyCharacteristicRequest$json = { '1': 'NotifyCharacteristicRequest', - '2': const [ - const {'1': 'characteristic', '3': 1, '4': 1, '5': 11, '6': '.CharacteristicAddress', '10': 'characteristic'}, + '2': [ + {'1': 'characteristic', '3': 1, '4': 1, '5': 11, '6': '.CharacteristicAddress', '10': 'characteristic'}, ], }; /// Descriptor for `NotifyCharacteristicRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List notifyCharacteristicRequestDescriptor = $convert.base64Decode('ChtOb3RpZnlDaGFyYWN0ZXJpc3RpY1JlcXVlc3QSPgoOY2hhcmFjdGVyaXN0aWMYASABKAsyFi5DaGFyYWN0ZXJpc3RpY0FkZHJlc3NSDmNoYXJhY3RlcmlzdGlj'); +final $typed_data.Uint8List notifyCharacteristicRequestDescriptor = $convert.base64Decode( + 'ChtOb3RpZnlDaGFyYWN0ZXJpc3RpY1JlcXVlc3QSPgoOY2hhcmFjdGVyaXN0aWMYASABKAsyFi' + '5DaGFyYWN0ZXJpc3RpY0FkZHJlc3NSDmNoYXJhY3RlcmlzdGlj'); + @$core.Deprecated('Use notifyNoMoreCharacteristicRequestDescriptor instead') -const NotifyNoMoreCharacteristicRequest$json = const { +const NotifyNoMoreCharacteristicRequest$json = { '1': 'NotifyNoMoreCharacteristicRequest', - '2': const [ - const {'1': 'characteristic', '3': 1, '4': 1, '5': 11, '6': '.CharacteristicAddress', '10': 'characteristic'}, + '2': [ + {'1': 'characteristic', '3': 1, '4': 1, '5': 11, '6': '.CharacteristicAddress', '10': 'characteristic'}, ], }; /// Descriptor for `NotifyNoMoreCharacteristicRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List notifyNoMoreCharacteristicRequestDescriptor = $convert.base64Decode('CiFOb3RpZnlOb01vcmVDaGFyYWN0ZXJpc3RpY1JlcXVlc3QSPgoOY2hhcmFjdGVyaXN0aWMYASABKAsyFi5DaGFyYWN0ZXJpc3RpY0FkZHJlc3NSDmNoYXJhY3RlcmlzdGlj'); +final $typed_data.Uint8List notifyNoMoreCharacteristicRequestDescriptor = $convert.base64Decode( + 'CiFOb3RpZnlOb01vcmVDaGFyYWN0ZXJpc3RpY1JlcXVlc3QSPgoOY2hhcmFjdGVyaXN0aWMYAS' + 'ABKAsyFi5DaGFyYWN0ZXJpc3RpY0FkZHJlc3NSDmNoYXJhY3RlcmlzdGlj'); + @$core.Deprecated('Use readCharacteristicRequestDescriptor instead') -const ReadCharacteristicRequest$json = const { +const ReadCharacteristicRequest$json = { '1': 'ReadCharacteristicRequest', - '2': const [ - const {'1': 'characteristic', '3': 1, '4': 1, '5': 11, '6': '.CharacteristicAddress', '10': 'characteristic'}, + '2': [ + {'1': 'characteristic', '3': 1, '4': 1, '5': 11, '6': '.CharacteristicAddress', '10': 'characteristic'}, ], }; /// Descriptor for `ReadCharacteristicRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List readCharacteristicRequestDescriptor = $convert.base64Decode('ChlSZWFkQ2hhcmFjdGVyaXN0aWNSZXF1ZXN0Ej4KDmNoYXJhY3RlcmlzdGljGAEgASgLMhYuQ2hhcmFjdGVyaXN0aWNBZGRyZXNzUg5jaGFyYWN0ZXJpc3RpYw=='); +final $typed_data.Uint8List readCharacteristicRequestDescriptor = $convert.base64Decode( + 'ChlSZWFkQ2hhcmFjdGVyaXN0aWNSZXF1ZXN0Ej4KDmNoYXJhY3RlcmlzdGljGAEgASgLMhYuQ2' + 'hhcmFjdGVyaXN0aWNBZGRyZXNzUg5jaGFyYWN0ZXJpc3RpYw=='); + @$core.Deprecated('Use characteristicValueInfoDescriptor instead') -const CharacteristicValueInfo$json = const { +const CharacteristicValueInfo$json = { '1': 'CharacteristicValueInfo', - '2': const [ - const {'1': 'characteristic', '3': 1, '4': 1, '5': 11, '6': '.CharacteristicAddress', '10': 'characteristic'}, - const {'1': 'value', '3': 2, '4': 1, '5': 12, '10': 'value'}, - const {'1': 'failure', '3': 3, '4': 1, '5': 11, '6': '.GenericFailure', '10': 'failure'}, + '2': [ + {'1': 'characteristic', '3': 1, '4': 1, '5': 11, '6': '.CharacteristicAddress', '10': 'characteristic'}, + {'1': 'value', '3': 2, '4': 1, '5': 12, '10': 'value'}, + {'1': 'failure', '3': 3, '4': 1, '5': 11, '6': '.GenericFailure', '10': 'failure'}, ], }; /// Descriptor for `CharacteristicValueInfo`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List characteristicValueInfoDescriptor = $convert.base64Decode('ChdDaGFyYWN0ZXJpc3RpY1ZhbHVlSW5mbxI+Cg5jaGFyYWN0ZXJpc3RpYxgBIAEoCzIWLkNoYXJhY3RlcmlzdGljQWRkcmVzc1IOY2hhcmFjdGVyaXN0aWMSFAoFdmFsdWUYAiABKAxSBXZhbHVlEikKB2ZhaWx1cmUYAyABKAsyDy5HZW5lcmljRmFpbHVyZVIHZmFpbHVyZQ=='); +final $typed_data.Uint8List characteristicValueInfoDescriptor = $convert.base64Decode( + 'ChdDaGFyYWN0ZXJpc3RpY1ZhbHVlSW5mbxI+Cg5jaGFyYWN0ZXJpc3RpYxgBIAEoCzIWLkNoYX' + 'JhY3RlcmlzdGljQWRkcmVzc1IOY2hhcmFjdGVyaXN0aWMSFAoFdmFsdWUYAiABKAxSBXZhbHVl' + 'EikKB2ZhaWx1cmUYAyABKAsyDy5HZW5lcmljRmFpbHVyZVIHZmFpbHVyZQ=='); + @$core.Deprecated('Use writeCharacteristicRequestDescriptor instead') -const WriteCharacteristicRequest$json = const { +const WriteCharacteristicRequest$json = { '1': 'WriteCharacteristicRequest', - '2': const [ - const {'1': 'characteristic', '3': 1, '4': 1, '5': 11, '6': '.CharacteristicAddress', '10': 'characteristic'}, - const {'1': 'value', '3': 2, '4': 1, '5': 12, '10': 'value'}, + '2': [ + {'1': 'characteristic', '3': 1, '4': 1, '5': 11, '6': '.CharacteristicAddress', '10': 'characteristic'}, + {'1': 'value', '3': 2, '4': 1, '5': 12, '10': 'value'}, ], }; /// Descriptor for `WriteCharacteristicRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List writeCharacteristicRequestDescriptor = $convert.base64Decode('ChpXcml0ZUNoYXJhY3RlcmlzdGljUmVxdWVzdBI+Cg5jaGFyYWN0ZXJpc3RpYxgBIAEoCzIWLkNoYXJhY3RlcmlzdGljQWRkcmVzc1IOY2hhcmFjdGVyaXN0aWMSFAoFdmFsdWUYAiABKAxSBXZhbHVl'); +final $typed_data.Uint8List writeCharacteristicRequestDescriptor = $convert.base64Decode( + 'ChpXcml0ZUNoYXJhY3RlcmlzdGljUmVxdWVzdBI+Cg5jaGFyYWN0ZXJpc3RpYxgBIAEoCzIWLk' + 'NoYXJhY3RlcmlzdGljQWRkcmVzc1IOY2hhcmFjdGVyaXN0aWMSFAoFdmFsdWUYAiABKAxSBXZh' + 'bHVl'); + @$core.Deprecated('Use writeCharacteristicInfoDescriptor instead') -const WriteCharacteristicInfo$json = const { +const WriteCharacteristicInfo$json = { '1': 'WriteCharacteristicInfo', - '2': const [ - const {'1': 'characteristic', '3': 1, '4': 1, '5': 11, '6': '.CharacteristicAddress', '10': 'characteristic'}, - const {'1': 'failure', '3': 3, '4': 1, '5': 11, '6': '.GenericFailure', '10': 'failure'}, + '2': [ + {'1': 'characteristic', '3': 1, '4': 1, '5': 11, '6': '.CharacteristicAddress', '10': 'characteristic'}, + {'1': 'failure', '3': 3, '4': 1, '5': 11, '6': '.GenericFailure', '10': 'failure'}, ], }; /// Descriptor for `WriteCharacteristicInfo`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List writeCharacteristicInfoDescriptor = $convert.base64Decode('ChdXcml0ZUNoYXJhY3RlcmlzdGljSW5mbxI+Cg5jaGFyYWN0ZXJpc3RpYxgBIAEoCzIWLkNoYXJhY3RlcmlzdGljQWRkcmVzc1IOY2hhcmFjdGVyaXN0aWMSKQoHZmFpbHVyZRgDIAEoCzIPLkdlbmVyaWNGYWlsdXJlUgdmYWlsdXJl'); +final $typed_data.Uint8List writeCharacteristicInfoDescriptor = $convert.base64Decode( + 'ChdXcml0ZUNoYXJhY3RlcmlzdGljSW5mbxI+Cg5jaGFyYWN0ZXJpc3RpYxgBIAEoCzIWLkNoYX' + 'JhY3RlcmlzdGljQWRkcmVzc1IOY2hhcmFjdGVyaXN0aWMSKQoHZmFpbHVyZRgDIAEoCzIPLkdl' + 'bmVyaWNGYWlsdXJlUgdmYWlsdXJl'); + @$core.Deprecated('Use negotiateMtuRequestDescriptor instead') -const NegotiateMtuRequest$json = const { +const NegotiateMtuRequest$json = { '1': 'NegotiateMtuRequest', - '2': const [ - const {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, - const {'1': 'mtuSize', '3': 2, '4': 1, '5': 5, '10': 'mtuSize'}, + '2': [ + {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, + {'1': 'mtuSize', '3': 2, '4': 1, '5': 5, '10': 'mtuSize'}, ], }; /// Descriptor for `NegotiateMtuRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List negotiateMtuRequestDescriptor = $convert.base64Decode('ChNOZWdvdGlhdGVNdHVSZXF1ZXN0EhoKCGRldmljZUlkGAEgASgJUghkZXZpY2VJZBIYCgdtdHVTaXplGAIgASgFUgdtdHVTaXpl'); +final $typed_data.Uint8List negotiateMtuRequestDescriptor = $convert.base64Decode( + 'ChNOZWdvdGlhdGVNdHVSZXF1ZXN0EhoKCGRldmljZUlkGAEgASgJUghkZXZpY2VJZBIYCgdtdH' + 'VTaXplGAIgASgFUgdtdHVTaXpl'); + @$core.Deprecated('Use negotiateMtuInfoDescriptor instead') -const NegotiateMtuInfo$json = const { +const NegotiateMtuInfo$json = { '1': 'NegotiateMtuInfo', - '2': const [ - const {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, - const {'1': 'mtuSize', '3': 2, '4': 1, '5': 5, '10': 'mtuSize'}, - const {'1': 'failure', '3': 3, '4': 1, '5': 11, '6': '.GenericFailure', '10': 'failure'}, + '2': [ + {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, + {'1': 'mtuSize', '3': 2, '4': 1, '5': 5, '10': 'mtuSize'}, + {'1': 'failure', '3': 3, '4': 1, '5': 11, '6': '.GenericFailure', '10': 'failure'}, ], }; /// Descriptor for `NegotiateMtuInfo`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List negotiateMtuInfoDescriptor = $convert.base64Decode('ChBOZWdvdGlhdGVNdHVJbmZvEhoKCGRldmljZUlkGAEgASgJUghkZXZpY2VJZBIYCgdtdHVTaXplGAIgASgFUgdtdHVTaXplEikKB2ZhaWx1cmUYAyABKAsyDy5HZW5lcmljRmFpbHVyZVIHZmFpbHVyZQ=='); +final $typed_data.Uint8List negotiateMtuInfoDescriptor = $convert.base64Decode( + 'ChBOZWdvdGlhdGVNdHVJbmZvEhoKCGRldmljZUlkGAEgASgJUghkZXZpY2VJZBIYCgdtdHVTaX' + 'plGAIgASgFUgdtdHVTaXplEikKB2ZhaWx1cmUYAyABKAsyDy5HZW5lcmljRmFpbHVyZVIHZmFp' + 'bHVyZQ=='); + @$core.Deprecated('Use bleStatusInfoDescriptor instead') -const BleStatusInfo$json = const { +const BleStatusInfo$json = { '1': 'BleStatusInfo', - '2': const [ - const {'1': 'status', '3': 1, '4': 1, '5': 5, '10': 'status'}, + '2': [ + {'1': 'status', '3': 1, '4': 1, '5': 5, '10': 'status'}, ], }; /// Descriptor for `BleStatusInfo`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List bleStatusInfoDescriptor = $convert.base64Decode('Cg1CbGVTdGF0dXNJbmZvEhYKBnN0YXR1cxgBIAEoBVIGc3RhdHVz'); +final $typed_data.Uint8List bleStatusInfoDescriptor = $convert.base64Decode( + 'Cg1CbGVTdGF0dXNJbmZvEhYKBnN0YXR1cxgBIAEoBVIGc3RhdHVz'); + @$core.Deprecated('Use changeConnectionPriorityRequestDescriptor instead') -const ChangeConnectionPriorityRequest$json = const { +const ChangeConnectionPriorityRequest$json = { '1': 'ChangeConnectionPriorityRequest', - '2': const [ - const {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, - const {'1': 'priority', '3': 2, '4': 1, '5': 5, '10': 'priority'}, + '2': [ + {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, + {'1': 'priority', '3': 2, '4': 1, '5': 5, '10': 'priority'}, ], }; /// Descriptor for `ChangeConnectionPriorityRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List changeConnectionPriorityRequestDescriptor = $convert.base64Decode('Ch9DaGFuZ2VDb25uZWN0aW9uUHJpb3JpdHlSZXF1ZXN0EhoKCGRldmljZUlkGAEgASgJUghkZXZpY2VJZBIaCghwcmlvcml0eRgCIAEoBVIIcHJpb3JpdHk='); +final $typed_data.Uint8List changeConnectionPriorityRequestDescriptor = $convert.base64Decode( + 'Ch9DaGFuZ2VDb25uZWN0aW9uUHJpb3JpdHlSZXF1ZXN0EhoKCGRldmljZUlkGAEgASgJUghkZX' + 'ZpY2VJZBIaCghwcmlvcml0eRgCIAEoBVIIcHJpb3JpdHk='); + @$core.Deprecated('Use changeConnectionPriorityInfoDescriptor instead') -const ChangeConnectionPriorityInfo$json = const { +const ChangeConnectionPriorityInfo$json = { '1': 'ChangeConnectionPriorityInfo', - '2': const [ - const {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, - const {'1': 'failure', '3': 2, '4': 1, '5': 11, '6': '.GenericFailure', '10': 'failure'}, + '2': [ + {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, + {'1': 'failure', '3': 2, '4': 1, '5': 11, '6': '.GenericFailure', '10': 'failure'}, ], }; /// Descriptor for `ChangeConnectionPriorityInfo`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List changeConnectionPriorityInfoDescriptor = $convert.base64Decode('ChxDaGFuZ2VDb25uZWN0aW9uUHJpb3JpdHlJbmZvEhoKCGRldmljZUlkGAEgASgJUghkZXZpY2VJZBIpCgdmYWlsdXJlGAIgASgLMg8uR2VuZXJpY0ZhaWx1cmVSB2ZhaWx1cmU='); +final $typed_data.Uint8List changeConnectionPriorityInfoDescriptor = $convert.base64Decode( + 'ChxDaGFuZ2VDb25uZWN0aW9uUHJpb3JpdHlJbmZvEhoKCGRldmljZUlkGAEgASgJUghkZXZpY2' + 'VJZBIpCgdmYWlsdXJlGAIgASgLMg8uR2VuZXJpY0ZhaWx1cmVSB2ZhaWx1cmU='); + @$core.Deprecated('Use characteristicAddressDescriptor instead') -const CharacteristicAddress$json = const { +const CharacteristicAddress$json = { '1': 'CharacteristicAddress', - '2': const [ - const {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, - const {'1': 'serviceUuid', '3': 2, '4': 1, '5': 11, '6': '.Uuid', '10': 'serviceUuid'}, - const {'1': 'characteristicUuid', '3': 3, '4': 1, '5': 11, '6': '.Uuid', '10': 'characteristicUuid'}, - const {'1': 'serviceInstanceId', '3': 4, '4': 1, '5': 9, '10': 'serviceInstanceId'}, - const {'1': 'characteristicInstanceId', '3': 5, '4': 1, '5': 9, '10': 'characteristicInstanceId'}, + '2': [ + {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, + {'1': 'serviceUuid', '3': 2, '4': 1, '5': 11, '6': '.Uuid', '10': 'serviceUuid'}, + {'1': 'characteristicUuid', '3': 3, '4': 1, '5': 11, '6': '.Uuid', '10': 'characteristicUuid'}, + {'1': 'serviceInstanceId', '3': 4, '4': 1, '5': 9, '10': 'serviceInstanceId'}, + {'1': 'characteristicInstanceId', '3': 5, '4': 1, '5': 9, '10': 'characteristicInstanceId'}, ], }; /// Descriptor for `CharacteristicAddress`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List characteristicAddressDescriptor = $convert.base64Decode('ChVDaGFyYWN0ZXJpc3RpY0FkZHJlc3MSGgoIZGV2aWNlSWQYASABKAlSCGRldmljZUlkEicKC3NlcnZpY2VVdWlkGAIgASgLMgUuVXVpZFILc2VydmljZVV1aWQSNQoSY2hhcmFjdGVyaXN0aWNVdWlkGAMgASgLMgUuVXVpZFISY2hhcmFjdGVyaXN0aWNVdWlkEiwKEXNlcnZpY2VJbnN0YW5jZUlkGAQgASgJUhFzZXJ2aWNlSW5zdGFuY2VJZBI6ChhjaGFyYWN0ZXJpc3RpY0luc3RhbmNlSWQYBSABKAlSGGNoYXJhY3RlcmlzdGljSW5zdGFuY2VJZA=='); +final $typed_data.Uint8List characteristicAddressDescriptor = $convert.base64Decode( + 'ChVDaGFyYWN0ZXJpc3RpY0FkZHJlc3MSGgoIZGV2aWNlSWQYASABKAlSCGRldmljZUlkEicKC3' + 'NlcnZpY2VVdWlkGAIgASgLMgUuVXVpZFILc2VydmljZVV1aWQSNQoSY2hhcmFjdGVyaXN0aWNV' + 'dWlkGAMgASgLMgUuVXVpZFISY2hhcmFjdGVyaXN0aWNVdWlkEiwKEXNlcnZpY2VJbnN0YW5jZU' + 'lkGAQgASgJUhFzZXJ2aWNlSW5zdGFuY2VJZBI6ChhjaGFyYWN0ZXJpc3RpY0luc3RhbmNlSWQY' + 'BSABKAlSGGNoYXJhY3RlcmlzdGljSW5zdGFuY2VJZA=='); + @$core.Deprecated('Use serviceDataEntryDescriptor instead') -const ServiceDataEntry$json = const { +const ServiceDataEntry$json = { '1': 'ServiceDataEntry', - '2': const [ - const {'1': 'serviceUuid', '3': 1, '4': 1, '5': 11, '6': '.Uuid', '10': 'serviceUuid'}, - const {'1': 'data', '3': 2, '4': 1, '5': 12, '10': 'data'}, + '2': [ + {'1': 'serviceUuid', '3': 1, '4': 1, '5': 11, '6': '.Uuid', '10': 'serviceUuid'}, + {'1': 'data', '3': 2, '4': 1, '5': 12, '10': 'data'}, ], }; /// Descriptor for `ServiceDataEntry`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List serviceDataEntryDescriptor = $convert.base64Decode('ChBTZXJ2aWNlRGF0YUVudHJ5EicKC3NlcnZpY2VVdWlkGAEgASgLMgUuVXVpZFILc2VydmljZVV1aWQSEgoEZGF0YRgCIAEoDFIEZGF0YQ=='); +final $typed_data.Uint8List serviceDataEntryDescriptor = $convert.base64Decode( + 'ChBTZXJ2aWNlRGF0YUVudHJ5EicKC3NlcnZpY2VVdWlkGAEgASgLMgUuVXVpZFILc2VydmljZV' + 'V1aWQSEgoEZGF0YRgCIAEoDFIEZGF0YQ=='); + @$core.Deprecated('Use servicesWithCharacteristicsDescriptor instead') -const ServicesWithCharacteristics$json = const { +const ServicesWithCharacteristics$json = { '1': 'ServicesWithCharacteristics', - '2': const [ - const {'1': 'items', '3': 1, '4': 3, '5': 11, '6': '.ServiceWithCharacteristics', '10': 'items'}, + '2': [ + {'1': 'items', '3': 1, '4': 3, '5': 11, '6': '.ServiceWithCharacteristics', '10': 'items'}, ], }; /// Descriptor for `ServicesWithCharacteristics`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List servicesWithCharacteristicsDescriptor = $convert.base64Decode('ChtTZXJ2aWNlc1dpdGhDaGFyYWN0ZXJpc3RpY3MSMQoFaXRlbXMYASADKAsyGy5TZXJ2aWNlV2l0aENoYXJhY3RlcmlzdGljc1IFaXRlbXM='); +final $typed_data.Uint8List servicesWithCharacteristicsDescriptor = $convert.base64Decode( + 'ChtTZXJ2aWNlc1dpdGhDaGFyYWN0ZXJpc3RpY3MSMQoFaXRlbXMYASADKAsyGy5TZXJ2aWNlV2' + 'l0aENoYXJhY3RlcmlzdGljc1IFaXRlbXM='); + @$core.Deprecated('Use serviceWithCharacteristicsDescriptor instead') -const ServiceWithCharacteristics$json = const { +const ServiceWithCharacteristics$json = { '1': 'ServiceWithCharacteristics', - '2': const [ - const {'1': 'serviceId', '3': 1, '4': 1, '5': 11, '6': '.Uuid', '10': 'serviceId'}, - const {'1': 'characteristics', '3': 2, '4': 3, '5': 11, '6': '.Uuid', '10': 'characteristics'}, + '2': [ + {'1': 'serviceId', '3': 1, '4': 1, '5': 11, '6': '.Uuid', '10': 'serviceId'}, + {'1': 'characteristics', '3': 2, '4': 3, '5': 11, '6': '.Uuid', '10': 'characteristics'}, ], }; /// Descriptor for `ServiceWithCharacteristics`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List serviceWithCharacteristicsDescriptor = $convert.base64Decode('ChpTZXJ2aWNlV2l0aENoYXJhY3RlcmlzdGljcxIjCglzZXJ2aWNlSWQYASABKAsyBS5VdWlkUglzZXJ2aWNlSWQSLwoPY2hhcmFjdGVyaXN0aWNzGAIgAygLMgUuVXVpZFIPY2hhcmFjdGVyaXN0aWNz'); +final $typed_data.Uint8List serviceWithCharacteristicsDescriptor = $convert.base64Decode( + 'ChpTZXJ2aWNlV2l0aENoYXJhY3RlcmlzdGljcxIjCglzZXJ2aWNlSWQYASABKAsyBS5VdWlkUg' + 'lzZXJ2aWNlSWQSLwoPY2hhcmFjdGVyaXN0aWNzGAIgAygLMgUuVXVpZFIPY2hhcmFjdGVyaXN0' + 'aWNz'); + @$core.Deprecated('Use discoverServicesRequestDescriptor instead') -const DiscoverServicesRequest$json = const { +const DiscoverServicesRequest$json = { '1': 'DiscoverServicesRequest', - '2': const [ - const {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, + '2': [ + {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, ], }; /// Descriptor for `DiscoverServicesRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List discoverServicesRequestDescriptor = $convert.base64Decode('ChdEaXNjb3ZlclNlcnZpY2VzUmVxdWVzdBIaCghkZXZpY2VJZBgBIAEoCVIIZGV2aWNlSWQ='); +final $typed_data.Uint8List discoverServicesRequestDescriptor = $convert.base64Decode( + 'ChdEaXNjb3ZlclNlcnZpY2VzUmVxdWVzdBIaCghkZXZpY2VJZBgBIAEoCVIIZGV2aWNlSWQ='); + @$core.Deprecated('Use discoverServicesInfoDescriptor instead') -const DiscoverServicesInfo$json = const { +const DiscoverServicesInfo$json = { '1': 'DiscoverServicesInfo', - '2': const [ - const {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, - const {'1': 'services', '3': 2, '4': 3, '5': 11, '6': '.DiscoveredService', '10': 'services'}, + '2': [ + {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, + {'1': 'services', '3': 2, '4': 3, '5': 11, '6': '.DiscoveredService', '10': 'services'}, ], }; /// Descriptor for `DiscoverServicesInfo`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List discoverServicesInfoDescriptor = $convert.base64Decode('ChREaXNjb3ZlclNlcnZpY2VzSW5mbxIaCghkZXZpY2VJZBgBIAEoCVIIZGV2aWNlSWQSLgoIc2VydmljZXMYAiADKAsyEi5EaXNjb3ZlcmVkU2VydmljZVIIc2VydmljZXM='); +final $typed_data.Uint8List discoverServicesInfoDescriptor = $convert.base64Decode( + 'ChREaXNjb3ZlclNlcnZpY2VzSW5mbxIaCghkZXZpY2VJZBgBIAEoCVIIZGV2aWNlSWQSLgoIc2' + 'VydmljZXMYAiADKAsyEi5EaXNjb3ZlcmVkU2VydmljZVIIc2VydmljZXM='); + @$core.Deprecated('Use discoveredServiceDescriptor instead') -const DiscoveredService$json = const { +const DiscoveredService$json = { '1': 'DiscoveredService', - '2': const [ - const {'1': 'serviceUuid', '3': 1, '4': 1, '5': 11, '6': '.Uuid', '10': 'serviceUuid'}, - const {'1': 'characteristicUuids', '3': 2, '4': 3, '5': 11, '6': '.Uuid', '10': 'characteristicUuids'}, - const {'1': 'includedServices', '3': 3, '4': 3, '5': 11, '6': '.DiscoveredService', '10': 'includedServices'}, - const {'1': 'characteristics', '3': 4, '4': 3, '5': 11, '6': '.DiscoveredCharacteristic', '10': 'characteristics'}, - const {'1': 'serviceInstanceId', '3': 5, '4': 1, '5': 9, '10': 'serviceInstanceId'}, + '2': [ + {'1': 'serviceUuid', '3': 1, '4': 1, '5': 11, '6': '.Uuid', '10': 'serviceUuid'}, + {'1': 'characteristicUuids', '3': 2, '4': 3, '5': 11, '6': '.Uuid', '10': 'characteristicUuids'}, + {'1': 'includedServices', '3': 3, '4': 3, '5': 11, '6': '.DiscoveredService', '10': 'includedServices'}, + {'1': 'characteristics', '3': 4, '4': 3, '5': 11, '6': '.DiscoveredCharacteristic', '10': 'characteristics'}, + {'1': 'serviceInstanceId', '3': 5, '4': 1, '5': 9, '10': 'serviceInstanceId'}, ], }; /// Descriptor for `DiscoveredService`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List discoveredServiceDescriptor = $convert.base64Decode('ChFEaXNjb3ZlcmVkU2VydmljZRInCgtzZXJ2aWNlVXVpZBgBIAEoCzIFLlV1aWRSC3NlcnZpY2VVdWlkEjcKE2NoYXJhY3RlcmlzdGljVXVpZHMYAiADKAsyBS5VdWlkUhNjaGFyYWN0ZXJpc3RpY1V1aWRzEj4KEGluY2x1ZGVkU2VydmljZXMYAyADKAsyEi5EaXNjb3ZlcmVkU2VydmljZVIQaW5jbHVkZWRTZXJ2aWNlcxJDCg9jaGFyYWN0ZXJpc3RpY3MYBCADKAsyGS5EaXNjb3ZlcmVkQ2hhcmFjdGVyaXN0aWNSD2NoYXJhY3RlcmlzdGljcxIsChFzZXJ2aWNlSW5zdGFuY2VJZBgFIAEoCVIRc2VydmljZUluc3RhbmNlSWQ='); +final $typed_data.Uint8List discoveredServiceDescriptor = $convert.base64Decode( + 'ChFEaXNjb3ZlcmVkU2VydmljZRInCgtzZXJ2aWNlVXVpZBgBIAEoCzIFLlV1aWRSC3NlcnZpY2' + 'VVdWlkEjcKE2NoYXJhY3RlcmlzdGljVXVpZHMYAiADKAsyBS5VdWlkUhNjaGFyYWN0ZXJpc3Rp' + 'Y1V1aWRzEj4KEGluY2x1ZGVkU2VydmljZXMYAyADKAsyEi5EaXNjb3ZlcmVkU2VydmljZVIQaW' + '5jbHVkZWRTZXJ2aWNlcxJDCg9jaGFyYWN0ZXJpc3RpY3MYBCADKAsyGS5EaXNjb3ZlcmVkQ2hh' + 'cmFjdGVyaXN0aWNSD2NoYXJhY3RlcmlzdGljcxIsChFzZXJ2aWNlSW5zdGFuY2VJZBgFIAEoCV' + 'IRc2VydmljZUluc3RhbmNlSWQ='); + @$core.Deprecated('Use discoveredCharacteristicDescriptor instead') -const DiscoveredCharacteristic$json = const { +const DiscoveredCharacteristic$json = { '1': 'DiscoveredCharacteristic', - '2': const [ - const {'1': 'characteristicId', '3': 1, '4': 1, '5': 11, '6': '.Uuid', '10': 'characteristicId'}, - const {'1': 'serviceId', '3': 2, '4': 1, '5': 11, '6': '.Uuid', '10': 'serviceId'}, - const {'1': 'isReadable', '3': 3, '4': 1, '5': 8, '10': 'isReadable'}, - const {'1': 'isWritableWithResponse', '3': 4, '4': 1, '5': 8, '10': 'isWritableWithResponse'}, - const {'1': 'isWritableWithoutResponse', '3': 5, '4': 1, '5': 8, '10': 'isWritableWithoutResponse'}, - const {'1': 'isNotifiable', '3': 6, '4': 1, '5': 8, '10': 'isNotifiable'}, - const {'1': 'isIndicatable', '3': 7, '4': 1, '5': 8, '10': 'isIndicatable'}, - const {'1': 'characteristicInstanceId', '3': 8, '4': 1, '5': 9, '10': 'characteristicInstanceId'}, + '2': [ + {'1': 'characteristicId', '3': 1, '4': 1, '5': 11, '6': '.Uuid', '10': 'characteristicId'}, + {'1': 'serviceId', '3': 2, '4': 1, '5': 11, '6': '.Uuid', '10': 'serviceId'}, + {'1': 'isReadable', '3': 3, '4': 1, '5': 8, '10': 'isReadable'}, + {'1': 'isWritableWithResponse', '3': 4, '4': 1, '5': 8, '10': 'isWritableWithResponse'}, + {'1': 'isWritableWithoutResponse', '3': 5, '4': 1, '5': 8, '10': 'isWritableWithoutResponse'}, + {'1': 'isNotifiable', '3': 6, '4': 1, '5': 8, '10': 'isNotifiable'}, + {'1': 'isIndicatable', '3': 7, '4': 1, '5': 8, '10': 'isIndicatable'}, + {'1': 'characteristicInstanceId', '3': 8, '4': 1, '5': 9, '10': 'characteristicInstanceId'}, ], }; /// Descriptor for `DiscoveredCharacteristic`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List discoveredCharacteristicDescriptor = $convert.base64Decode('ChhEaXNjb3ZlcmVkQ2hhcmFjdGVyaXN0aWMSMQoQY2hhcmFjdGVyaXN0aWNJZBgBIAEoCzIFLlV1aWRSEGNoYXJhY3RlcmlzdGljSWQSIwoJc2VydmljZUlkGAIgASgLMgUuVXVpZFIJc2VydmljZUlkEh4KCmlzUmVhZGFibGUYAyABKAhSCmlzUmVhZGFibGUSNgoWaXNXcml0YWJsZVdpdGhSZXNwb25zZRgEIAEoCFIWaXNXcml0YWJsZVdpdGhSZXNwb25zZRI8Chlpc1dyaXRhYmxlV2l0aG91dFJlc3BvbnNlGAUgASgIUhlpc1dyaXRhYmxlV2l0aG91dFJlc3BvbnNlEiIKDGlzTm90aWZpYWJsZRgGIAEoCFIMaXNOb3RpZmlhYmxlEiQKDWlzSW5kaWNhdGFibGUYByABKAhSDWlzSW5kaWNhdGFibGUSOgoYY2hhcmFjdGVyaXN0aWNJbnN0YW5jZUlkGAggASgJUhhjaGFyYWN0ZXJpc3RpY0luc3RhbmNlSWQ='); +final $typed_data.Uint8List discoveredCharacteristicDescriptor = $convert.base64Decode( + 'ChhEaXNjb3ZlcmVkQ2hhcmFjdGVyaXN0aWMSMQoQY2hhcmFjdGVyaXN0aWNJZBgBIAEoCzIFLl' + 'V1aWRSEGNoYXJhY3RlcmlzdGljSWQSIwoJc2VydmljZUlkGAIgASgLMgUuVXVpZFIJc2Vydmlj' + 'ZUlkEh4KCmlzUmVhZGFibGUYAyABKAhSCmlzUmVhZGFibGUSNgoWaXNXcml0YWJsZVdpdGhSZX' + 'Nwb25zZRgEIAEoCFIWaXNXcml0YWJsZVdpdGhSZXNwb25zZRI8Chlpc1dyaXRhYmxlV2l0aG91' + 'dFJlc3BvbnNlGAUgASgIUhlpc1dyaXRhYmxlV2l0aG91dFJlc3BvbnNlEiIKDGlzTm90aWZpYW' + 'JsZRgGIAEoCFIMaXNOb3RpZmlhYmxlEiQKDWlzSW5kaWNhdGFibGUYByABKAhSDWlzSW5kaWNh' + 'dGFibGUSOgoYY2hhcmFjdGVyaXN0aWNJbnN0YW5jZUlkGAggASgJUhhjaGFyYWN0ZXJpc3RpY0' + 'luc3RhbmNlSWQ='); + @$core.Deprecated('Use readRssiRequestDescriptor instead') -const ReadRssiRequest$json = const { +const ReadRssiRequest$json = { '1': 'ReadRssiRequest', - '2': const [ - const {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, + '2': [ + {'1': 'deviceId', '3': 1, '4': 1, '5': 9, '10': 'deviceId'}, ], }; /// Descriptor for `ReadRssiRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List readRssiRequestDescriptor = $convert.base64Decode('Cg9SZWFkUnNzaVJlcXVlc3QSGgoIZGV2aWNlSWQYASABKAlSCGRldmljZUlk'); +final $typed_data.Uint8List readRssiRequestDescriptor = $convert.base64Decode( + 'Cg9SZWFkUnNzaVJlcXVlc3QSGgoIZGV2aWNlSWQYASABKAlSCGRldmljZUlk'); + @$core.Deprecated('Use readRssiResultDescriptor instead') -const ReadRssiResult$json = const { +const ReadRssiResult$json = { '1': 'ReadRssiResult', - '2': const [ - const {'1': 'rssi', '3': 1, '4': 1, '5': 5, '10': 'rssi'}, + '2': [ + {'1': 'rssi', '3': 1, '4': 1, '5': 5, '10': 'rssi'}, ], }; /// Descriptor for `ReadRssiResult`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List readRssiResultDescriptor = $convert.base64Decode('Cg5SZWFkUnNzaVJlc3VsdBISCgRyc3NpGAEgASgFUgRyc3Np'); +final $typed_data.Uint8List readRssiResultDescriptor = $convert.base64Decode( + 'Cg5SZWFkUnNzaVJlc3VsdBISCgRyc3NpGAEgASgFUgRyc3Np'); + +@$core.Deprecated('Use deviceInfoCollectionDescriptor instead') +const DeviceInfoCollection$json = { + '1': 'DeviceInfoCollection', + '2': [ + {'1': 'devices', '3': 1, '4': 3, '5': 11, '6': '.DeviceInfo', '10': 'devices'}, + ], +}; + +/// Descriptor for `DeviceInfoCollection`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List deviceInfoCollectionDescriptor = $convert.base64Decode( + 'ChREZXZpY2VJbmZvQ29sbGVjdGlvbhIlCgdkZXZpY2VzGAEgAygLMgsuRGV2aWNlSW5mb1IHZG' + 'V2aWNlcw=='); + @$core.Deprecated('Use uuidDescriptor instead') -const Uuid$json = const { +const Uuid$json = { '1': 'Uuid', - '2': const [ - const {'1': 'data', '3': 1, '4': 1, '5': 12, '10': 'data'}, + '2': [ + {'1': 'data', '3': 1, '4': 1, '5': 12, '10': 'data'}, ], }; /// Descriptor for `Uuid`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List uuidDescriptor = $convert.base64Decode('CgRVdWlkEhIKBGRhdGEYASABKAxSBGRhdGE='); +final $typed_data.Uint8List uuidDescriptor = $convert.base64Decode( + 'CgRVdWlkEhIKBGRhdGEYASABKAxSBGRhdGE='); + @$core.Deprecated('Use genericFailureDescriptor instead') -const GenericFailure$json = const { +const GenericFailure$json = { '1': 'GenericFailure', - '2': const [ - const {'1': 'code', '3': 1, '4': 1, '5': 5, '10': 'code'}, - const {'1': 'message', '3': 2, '4': 1, '5': 9, '10': 'message'}, + '2': [ + {'1': 'code', '3': 1, '4': 1, '5': 5, '10': 'code'}, + {'1': 'message', '3': 2, '4': 1, '5': 9, '10': 'message'}, ], }; /// Descriptor for `GenericFailure`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List genericFailureDescriptor = $convert.base64Decode('Cg5HZW5lcmljRmFpbHVyZRISCgRjb2RlGAEgASgFUgRjb2RlEhgKB21lc3NhZ2UYAiABKAlSB21lc3NhZ2U='); +final $typed_data.Uint8List genericFailureDescriptor = $convert.base64Decode( + 'Cg5HZW5lcmljRmFpbHVyZRISCgRjb2RlGAEgASgFUgRjb2RlEhgKB21lc3NhZ2UYAiABKAlSB2' + '1lc3NhZ2U='); + @$core.Deprecated('Use isConnectableDescriptor instead') -const IsConnectable$json = const { +const IsConnectable$json = { '1': 'IsConnectable', - '2': const [ - const {'1': 'code', '3': 1, '4': 1, '5': 5, '10': 'code'}, + '2': [ + {'1': 'code', '3': 1, '4': 1, '5': 5, '10': 'code'}, ], }; /// Descriptor for `IsConnectable`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List isConnectableDescriptor = $convert.base64Decode('Cg1Jc0Nvbm5lY3RhYmxlEhIKBGNvZGUYASABKAVSBGNvZGU='); +final $typed_data.Uint8List isConnectableDescriptor = $convert.base64Decode( + 'Cg1Jc0Nvbm5lY3RhYmxlEhIKBGNvZGUYASABKAVSBGNvZGU='); + diff --git a/packages/reactive_ble_mobile/lib/src/generated/bledata.pbserver.dart b/packages/reactive_ble_mobile/lib/src/generated/bledata.pbserver.dart index d859c88b..bca5dade 100644 --- a/packages/reactive_ble_mobile/lib/src/generated/bledata.pbserver.dart +++ b/packages/reactive_ble_mobile/lib/src/generated/bledata.pbserver.dart @@ -1,9 +1,14 @@ -/// +// // Generated code. Do not modify. // source: bledata.proto // // @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,deprecated_member_use_from_same_package,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names +// ignore_for_file: deprecated_member_use_from_same_package, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import export 'bledata.pb.dart'; diff --git a/packages/reactive_ble_mobile/lib/src/reactive_ble_mobile_platform.dart b/packages/reactive_ble_mobile/lib/src/reactive_ble_mobile_platform.dart index 2c36a366..02246116 100644 --- a/packages/reactive_ble_mobile/lib/src/reactive_ble_mobile_platform.dart +++ b/packages/reactive_ble_mobile/lib/src/reactive_ble_mobile_platform.dart @@ -9,34 +9,54 @@ class ReactiveBleMobilePlatform extends ReactiveBlePlatform { required ArgsToProtobufConverter argsToProtobufConverter, required ProtobufConverter protobufConverter, required MethodChannel bleMethodChannel, + required Stream> bondUpdateChannel, required Stream> connectedDeviceChannel, + required Stream> restoredDeviceChannel, required Stream> charUpdateChannel, required Stream> bleDeviceScanChannel, required Stream> bleStatusChannel, Logger? logger, + String? restorationKey, }) : _argsToProtobufConverter = argsToProtobufConverter, _protobufConverter = protobufConverter, _bleMethodChannel = bleMethodChannel, + _bondUpdateRawStream = bondUpdateChannel, _connectedDeviceRawStream = connectedDeviceChannel, + _restoredDeviceRawStream = restoredDeviceChannel, _charUpdateRawStream = charUpdateChannel, _bleStatusRawChannel = bleStatusChannel, _bleDeviceScanRawStream = bleDeviceScanChannel, - _logger = logger; + _logger = logger, + _restorationKey = restorationKey; final ArgsToProtobufConverter _argsToProtobufConverter; final ProtobufConverter _protobufConverter; final MethodChannel _bleMethodChannel; + final Stream> _bondUpdateRawStream; final Stream> _connectedDeviceRawStream; + final Stream> _restoredDeviceRawStream; final Stream> _charUpdateRawStream; final Stream> _bleDeviceScanRawStream; final Stream> _bleStatusRawChannel; final Logger? _logger; + final String? _restorationKey; Stream? _connectionUpdateStream; Stream? _charValueStream; Stream? _scanResultStream; Stream? _bleStatusStream; + @override + Stream get bondUpdateStream => + _bondUpdateRawStream.map(_protobufConverter.bondUpdateFrom).map( + (update) { + _logger?.log( + 'Received $BondStateUpdate(deviceId: ${update.deviceId}, connectionState: ${update.bondState})', + ); + return update; + }, + ); + @override Stream get connectionUpdateStream => _connectionUpdateStream ??= _connectedDeviceRawStream @@ -50,6 +70,16 @@ class ReactiveBleMobilePlatform extends ReactiveBlePlatform { }, ); + @override + Stream get restoredDeviceStream => + _restoredDeviceRawStream + .map(_protobufConverter.restoredDevicesFrom) + .take(1) + .expand((devices) { + _logger?.log('Received $devices'); + return devices; + }); + @override Stream get charValueUpdateStream => _charValueStream ??= _charUpdateRawStream @@ -86,7 +116,11 @@ class ReactiveBleMobilePlatform extends ReactiveBlePlatform { @override Future initialize() { _logger?.log('Initialize BLE platform'); - return _bleMethodChannel.invokeMethod("initialize"); + return _bleMethodChannel.invokeMethod( + "initialize", + _argsToProtobufConverter + .createInitializationRequest(_restorationKey) + .writeToBuffer()); } @override @@ -317,11 +351,14 @@ class ReactiveBleMobilePlatform extends ReactiveBlePlatform { class ReactiveBleMobilePlatformFactory { const ReactiveBleMobilePlatformFactory(); - ReactiveBleMobilePlatform create({Logger? logger}) { + ReactiveBleMobilePlatform create({Logger? logger, String? restorationKey}) { const _bleMethodChannel = MethodChannel("flutter_reactive_ble_method"); const connectedDeviceChannel = EventChannel("flutter_reactive_ble_connected_device"); + const restoredDeviceChannel = + EventChannel("flutter_reactive_ble_restored_device"); + const bondEventChannel = EventChannel("flutter_reactive_ble_bond_update"); const charEventChannel = EventChannel("flutter_reactive_ble_char_update"); const scanEventChannel = EventChannel("flutter_reactive_ble_scan"); const bleStatusChannel = EventChannel("flutter_reactive_ble_status"); @@ -330,8 +367,12 @@ class ReactiveBleMobilePlatformFactory { protobufConverter: const ProtobufConverterImpl(), argsToProtobufConverter: const ArgsToProtobufConverterImpl(), bleMethodChannel: _bleMethodChannel, + bondUpdateChannel: + bondEventChannel.receiveBroadcastStream().cast>(), connectedDeviceChannel: connectedDeviceChannel.receiveBroadcastStream().cast>(), + restoredDeviceChannel: + restoredDeviceChannel.receiveBroadcastStream().cast>(), charUpdateChannel: charEventChannel.receiveBroadcastStream().cast>(), bleDeviceScanChannel: @@ -339,6 +380,7 @@ class ReactiveBleMobilePlatformFactory { bleStatusChannel: bleStatusChannel.receiveBroadcastStream().cast>(), logger: logger, + restorationKey: restorationKey, ); } } diff --git a/packages/reactive_ble_mobile/protos/bledata.proto b/packages/reactive_ble_mobile/protos/bledata.proto index 4e80f442..0f090d38 100644 --- a/packages/reactive_ble_mobile/protos/bledata.proto +++ b/packages/reactive_ble_mobile/protos/bledata.proto @@ -2,6 +2,10 @@ syntax = "proto3"; option java_package = "com.signify.hue.flutterreactiveble"; option java_outer_classname = "ProtobufModel"; +message InitializationRequest { + string restorationKey = 1; +} + message ScanForDevicesRequest { repeated Uuid serviceUuids = 1; int32 scanMode = 2; @@ -25,12 +29,27 @@ message ConnectToDeviceRequest { int32 timeoutInMs = 3; } +message BondInfo { + string id = 1; + int32 bondState = 2; +} + message DeviceInfo { string id = 1; int32 connectionState = 2; GenericFailure failure = 3; } +message RestoredDeviceInfo { + string id = 1; + string name = 2; + repeated CharacteristicAddress subscriptions = 3; +} + +message RestoredDeviceInfoCollection { + repeated RestoredDeviceInfo devices = 1; +} + message DisconnectFromDeviceRequest { string deviceId = 1; } @@ -154,6 +173,10 @@ message ReadRssiResult { int32 rssi = 1; } +message DeviceInfoCollection { + repeated DeviceInfo devices = 1; +} + message Uuid { bytes data = 1; } diff --git a/packages/reactive_ble_mobile/pubspec.lock b/packages/reactive_ble_mobile/pubspec.lock index b5e65eae..db7438c2 100644 --- a/packages/reactive_ble_mobile/pubspec.lock +++ b/packages/reactive_ble_mobile/pubspec.lock @@ -287,26 +287,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" url: "https://pub.dev" source: hosted - version: "10.0.0" + version: "10.0.5" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.5" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.1" lints: dependency: transitive description: @@ -335,18 +335,18 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec url: "https://pub.dev" source: hosted - version: "0.8.0" + version: "0.11.1" meta: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.15.0" mime: dependency: transitive description: @@ -507,10 +507,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.2" timing: dependency: transitive description: @@ -539,10 +539,10 @@ packages: dependency: transitive description: name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "13.0.0" + version: "14.2.5" watcher: dependency: transitive description: @@ -577,4 +577,4 @@ packages: version: "3.1.2" sdks: dart: ">=3.3.0 <4.0.0" - flutter: ">=2.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/packages/reactive_ble_mobile/test/reactive_ble_platform_test.dart b/packages/reactive_ble_mobile/test/reactive_ble_platform_test.dart index ea60c6a4..42b4b1b7 100644 --- a/packages/reactive_ble_mobile/test/reactive_ble_platform_test.dart +++ b/packages/reactive_ble_mobile/test/reactive_ble_platform_test.dart @@ -22,11 +22,15 @@ import 'reactive_ble_platform_test.mocks.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); group('$ReactiveBleMobilePlatform', () { + const restorationKey = 'key'; + late ReactiveBleMobilePlatform _sut; late MockMethodChannel _methodChannel; late ArgsToProtobufConverter _argsConverter; late ProtobufConverter _protobufConverter; + late StreamController> _bondUpdateStreamController; late StreamController> _connectedDeviceStreamController; + late StreamController> _restoredDeviceStreamController; late StreamController> _argsStreamController; late StreamController> _scanStreamController; late StreamController> _statusStreamController; @@ -35,7 +39,9 @@ void main() { _argsConverter = MockArgsToProtobufConverter(); _methodChannel = MockMethodChannel(); _protobufConverter = MockProtobufConverter(); + _bondUpdateStreamController = StreamController(); _connectedDeviceStreamController = StreamController(); + _restoredDeviceStreamController = StreamController(); _argsStreamController = StreamController(); _scanStreamController = StreamController(); _statusStreamController = StreamController(); @@ -48,15 +54,20 @@ void main() { argsToProtobufConverter: _argsConverter, bleMethodChannel: _methodChannel, protobufConverter: _protobufConverter, + bondUpdateChannel: _bondUpdateStreamController.stream, connectedDeviceChannel: _connectedDeviceStreamController.stream, + restoredDeviceChannel: _restoredDeviceStreamController.stream, charUpdateChannel: _argsStreamController.stream, bleDeviceScanChannel: _scanStreamController.stream, bleStatusChannel: _statusStreamController.stream, + restorationKey: restorationKey, ); }); tearDown(() { + _bondUpdateStreamController.close(); _connectedDeviceStreamController.close(); + _restoredDeviceStreamController.close(); _argsStreamController.close(); _scanStreamController.close(); _statusStreamController.close(); @@ -272,8 +283,8 @@ void main() { ); expectedResult = WriteCharacteristicInfo( - characteristic: characteristic, - result: const Result.success(Unit()), + characteristic: characteristic, + result: const Result.success(Unit()), ); when(_methodChannel.invokeMethod?>(any, any)).thenAnswer( @@ -525,12 +536,20 @@ void main() { }); group('initialize', () { + late pb.InitializationRequest request; + setUp(() async { + request = pb.InitializationRequest(restorationKey: restorationKey); + when(_argsConverter.createInitializationRequest(restorationKey)) + .thenReturn(request); + await _sut.initialize(); }); test('It invokes correct method in method channel', () { - verify(_methodChannel.invokeMethod('initialize')).called(1); - expect(true, true); + verify(_methodChannel.invokeMethod( + 'initialize', + request.writeToBuffer(), + )).called(1); }); }); @@ -606,6 +625,41 @@ void main() { }); }); + group('bond status', () { + const status1 = BondStateUpdate( + deviceId: '123', + bondState: DeviceBondState.unknown, + ); + + const status2 = BondStateUpdate( + deviceId: '123', + bondState: DeviceBondState.bonding, + ); + + Stream? _bondUpdateStream; + + setUp(() { + _bondUpdateStreamController.addStream( + Stream>.fromIterable([ + [1], + [0] + ]), + ); + + when(_protobufConverter.bondUpdateFrom([1])).thenReturn(status1); + when(_protobufConverter.bondUpdateFrom([0])).thenReturn(status2); + + _bondUpdateStream = _sut.bondUpdateStream; + }); + + test('It emits correct values', () { + expect( + _bondUpdateStream, + emitsInOrder([status1, status2]), + ); + }); + }); + group('Discover services', () { const deviceId = "testdevice"; late pb.DiscoverServicesRequest request; diff --git a/packages/reactive_ble_mobile/test/reactive_ble_platform_test.mocks.dart b/packages/reactive_ble_mobile/test/reactive_ble_platform_test.mocks.dart index caea5db2..7fd4dd53 100644 --- a/packages/reactive_ble_mobile/test/reactive_ble_platform_test.mocks.dart +++ b/packages/reactive_ble_mobile/test/reactive_ble_platform_test.mocks.dart @@ -1,14 +1,15 @@ -// Mocks generated by Mockito 5.4.0 from annotations +// Mocks generated by Mockito 5.4.4 from annotations // in reactive_ble_mobile/test/reactive_ble_platform_test.dart. // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i9; +import 'dart:async' as _i10; import 'package:flutter/src/services/binary_messenger.dart' as _i5; import 'package:flutter/src/services/message_codec.dart' as _i4; import 'package:flutter/src/services/platform_channel.dart' as _i8; import 'package:mockito/mockito.dart' as _i1; +import 'package:mockito/src/dummies.dart' as _i9; import 'package:reactive_ble_mobile/src/converter/args_to_protubuf_converter.dart' as _i6; import 'package:reactive_ble_mobile/src/converter/protobuf_converter.dart' @@ -21,6 +22,8 @@ import 'package:reactive_ble_platform_interface/reactive_ble_platform_interface. // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors @@ -28,9 +31,20 @@ import 'package:reactive_ble_platform_interface/reactive_ble_platform_interface. // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class -class _FakeConnectToDeviceRequest_0 extends _i1.SmartFake +class _FakeInitializationRequest_0 extends _i1.SmartFake + implements _i2.InitializationRequest { + _FakeInitializationRequest_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeConnectToDeviceRequest_1 extends _i1.SmartFake implements _i2.ConnectToDeviceRequest { - _FakeConnectToDeviceRequest_0( + _FakeConnectToDeviceRequest_1( Object parent, Invocation parentInvocation, ) : super( @@ -39,9 +53,9 @@ class _FakeConnectToDeviceRequest_0 extends _i1.SmartFake ); } -class _FakeDisconnectFromDeviceRequest_1 extends _i1.SmartFake +class _FakeDisconnectFromDeviceRequest_2 extends _i1.SmartFake implements _i2.DisconnectFromDeviceRequest { - _FakeDisconnectFromDeviceRequest_1( + _FakeDisconnectFromDeviceRequest_2( Object parent, Invocation parentInvocation, ) : super( @@ -50,9 +64,9 @@ class _FakeDisconnectFromDeviceRequest_1 extends _i1.SmartFake ); } -class _FakeReadCharacteristicRequest_2 extends _i1.SmartFake +class _FakeReadCharacteristicRequest_3 extends _i1.SmartFake implements _i2.ReadCharacteristicRequest { - _FakeReadCharacteristicRequest_2( + _FakeReadCharacteristicRequest_3( Object parent, Invocation parentInvocation, ) : super( @@ -61,9 +75,9 @@ class _FakeReadCharacteristicRequest_2 extends _i1.SmartFake ); } -class _FakeWriteCharacteristicRequest_3 extends _i1.SmartFake +class _FakeWriteCharacteristicRequest_4 extends _i1.SmartFake implements _i2.WriteCharacteristicRequest { - _FakeWriteCharacteristicRequest_3( + _FakeWriteCharacteristicRequest_4( Object parent, Invocation parentInvocation, ) : super( @@ -72,9 +86,9 @@ class _FakeWriteCharacteristicRequest_3 extends _i1.SmartFake ); } -class _FakeNotifyCharacteristicRequest_4 extends _i1.SmartFake +class _FakeNotifyCharacteristicRequest_5 extends _i1.SmartFake implements _i2.NotifyCharacteristicRequest { - _FakeNotifyCharacteristicRequest_4( + _FakeNotifyCharacteristicRequest_5( Object parent, Invocation parentInvocation, ) : super( @@ -83,9 +97,9 @@ class _FakeNotifyCharacteristicRequest_4 extends _i1.SmartFake ); } -class _FakeNotifyNoMoreCharacteristicRequest_5 extends _i1.SmartFake +class _FakeNotifyNoMoreCharacteristicRequest_6 extends _i1.SmartFake implements _i2.NotifyNoMoreCharacteristicRequest { - _FakeNotifyNoMoreCharacteristicRequest_5( + _FakeNotifyNoMoreCharacteristicRequest_6( Object parent, Invocation parentInvocation, ) : super( @@ -94,9 +108,9 @@ class _FakeNotifyNoMoreCharacteristicRequest_5 extends _i1.SmartFake ); } -class _FakeNegotiateMtuRequest_6 extends _i1.SmartFake +class _FakeNegotiateMtuRequest_7 extends _i1.SmartFake implements _i2.NegotiateMtuRequest { - _FakeNegotiateMtuRequest_6( + _FakeNegotiateMtuRequest_7( Object parent, Invocation parentInvocation, ) : super( @@ -105,9 +119,9 @@ class _FakeNegotiateMtuRequest_6 extends _i1.SmartFake ); } -class _FakeChangeConnectionPriorityRequest_7 extends _i1.SmartFake +class _FakeChangeConnectionPriorityRequest_8 extends _i1.SmartFake implements _i2.ChangeConnectionPriorityRequest { - _FakeChangeConnectionPriorityRequest_7( + _FakeChangeConnectionPriorityRequest_8( Object parent, Invocation parentInvocation, ) : super( @@ -116,9 +130,9 @@ class _FakeChangeConnectionPriorityRequest_7 extends _i1.SmartFake ); } -class _FakeScanForDevicesRequest_8 extends _i1.SmartFake +class _FakeScanForDevicesRequest_9 extends _i1.SmartFake implements _i2.ScanForDevicesRequest { - _FakeScanForDevicesRequest_8( + _FakeScanForDevicesRequest_9( Object parent, Invocation parentInvocation, ) : super( @@ -127,9 +141,9 @@ class _FakeScanForDevicesRequest_8 extends _i1.SmartFake ); } -class _FakeClearGattCacheRequest_9 extends _i1.SmartFake +class _FakeClearGattCacheRequest_10 extends _i1.SmartFake implements _i2.ClearGattCacheRequest { - _FakeClearGattCacheRequest_9( + _FakeClearGattCacheRequest_10( Object parent, Invocation parentInvocation, ) : super( @@ -138,9 +152,9 @@ class _FakeClearGattCacheRequest_9 extends _i1.SmartFake ); } -class _FakeDiscoverServicesRequest_10 extends _i1.SmartFake +class _FakeDiscoverServicesRequest_11 extends _i1.SmartFake implements _i2.DiscoverServicesRequest { - _FakeDiscoverServicesRequest_10( + _FakeDiscoverServicesRequest_11( Object parent, Invocation parentInvocation, ) : super( @@ -149,9 +163,19 @@ class _FakeDiscoverServicesRequest_10 extends _i1.SmartFake ); } -class _FakeReadRssiRequest_11 extends _i1.SmartFake +class _FakeReadRssiRequest_12 extends _i1.SmartFake implements _i2.ReadRssiRequest { - _FakeReadRssiRequest_11( + _FakeReadRssiRequest_12( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeScanResult_13 extends _i1.SmartFake implements _i3.ScanResult { + _FakeScanResult_13( Object parent, Invocation parentInvocation, ) : super( @@ -160,8 +184,9 @@ class _FakeReadRssiRequest_11 extends _i1.SmartFake ); } -class _FakeScanResult_12 extends _i1.SmartFake implements _i3.ScanResult { - _FakeScanResult_12( +class _FakeBondStateUpdate_14 extends _i1.SmartFake + implements _i3.BondStateUpdate { + _FakeBondStateUpdate_14( Object parent, Invocation parentInvocation, ) : super( @@ -170,9 +195,9 @@ class _FakeScanResult_12 extends _i1.SmartFake implements _i3.ScanResult { ); } -class _FakeConnectionStateUpdate_13 extends _i1.SmartFake +class _FakeConnectionStateUpdate_15 extends _i1.SmartFake implements _i3.ConnectionStateUpdate { - _FakeConnectionStateUpdate_13( + _FakeConnectionStateUpdate_15( Object parent, Invocation parentInvocation, ) : super( @@ -181,9 +206,9 @@ class _FakeConnectionStateUpdate_13 extends _i1.SmartFake ); } -class _FakeResult_14 extends _i1.SmartFake +class _FakeResult_16 extends _i1.SmartFake implements _i3.Result { - _FakeResult_14( + _FakeResult_16( Object parent, Invocation parentInvocation, ) : super( @@ -192,9 +217,9 @@ class _FakeResult_14 extends _i1.SmartFake ); } -class _FakeCharacteristicValue_15 extends _i1.SmartFake +class _FakeCharacteristicValue_17 extends _i1.SmartFake implements _i3.CharacteristicValue { - _FakeCharacteristicValue_15( + _FakeCharacteristicValue_17( Object parent, Invocation parentInvocation, ) : super( @@ -203,9 +228,9 @@ class _FakeCharacteristicValue_15 extends _i1.SmartFake ); } -class _FakeWriteCharacteristicInfo_16 extends _i1.SmartFake +class _FakeWriteCharacteristicInfo_18 extends _i1.SmartFake implements _i3.WriteCharacteristicInfo { - _FakeWriteCharacteristicInfo_16( + _FakeWriteCharacteristicInfo_18( Object parent, Invocation parentInvocation, ) : super( @@ -214,9 +239,9 @@ class _FakeWriteCharacteristicInfo_16 extends _i1.SmartFake ); } -class _FakeConnectionPriorityInfo_17 extends _i1.SmartFake +class _FakeConnectionPriorityInfo_19 extends _i1.SmartFake implements _i3.ConnectionPriorityInfo { - _FakeConnectionPriorityInfo_17( + _FakeConnectionPriorityInfo_19( Object parent, Invocation parentInvocation, ) : super( @@ -225,8 +250,8 @@ class _FakeConnectionPriorityInfo_17 extends _i1.SmartFake ); } -class _FakeMethodCodec_18 extends _i1.SmartFake implements _i4.MethodCodec { - _FakeMethodCodec_18( +class _FakeMethodCodec_20 extends _i1.SmartFake implements _i4.MethodCodec { + _FakeMethodCodec_20( Object parent, Invocation parentInvocation, ) : super( @@ -235,9 +260,9 @@ class _FakeMethodCodec_18 extends _i1.SmartFake implements _i4.MethodCodec { ); } -class _FakeBinaryMessenger_19 extends _i1.SmartFake +class _FakeBinaryMessenger_21 extends _i1.SmartFake implements _i5.BinaryMessenger { - _FakeBinaryMessenger_19( + _FakeBinaryMessenger_21( Object parent, Invocation parentInvocation, ) : super( @@ -255,6 +280,23 @@ class MockArgsToProtobufConverter extends _i1.Mock _i1.throwOnMissingStub(this); } + @override + _i2.InitializationRequest createInitializationRequest( + String? restorationKey) => + (super.noSuchMethod( + Invocation.method( + #createInitializationRequest, + [restorationKey], + ), + returnValue: _FakeInitializationRequest_0( + this, + Invocation.method( + #createInitializationRequest, + [restorationKey], + ), + ), + ) as _i2.InitializationRequest); + @override _i2.ConnectToDeviceRequest createConnectToDeviceArgs( String? id, @@ -270,7 +312,7 @@ class MockArgsToProtobufConverter extends _i1.Mock connectionTimeout, ], ), - returnValue: _FakeConnectToDeviceRequest_0( + returnValue: _FakeConnectToDeviceRequest_1( this, Invocation.method( #createConnectToDeviceArgs, @@ -282,6 +324,7 @@ class MockArgsToProtobufConverter extends _i1.Mock ), ), ) as _i2.ConnectToDeviceRequest); + @override _i2.DisconnectFromDeviceRequest createDisconnectDeviceArgs( String? deviceId) => @@ -290,7 +333,7 @@ class MockArgsToProtobufConverter extends _i1.Mock #createDisconnectDeviceArgs, [deviceId], ), - returnValue: _FakeDisconnectFromDeviceRequest_1( + returnValue: _FakeDisconnectFromDeviceRequest_2( this, Invocation.method( #createDisconnectDeviceArgs, @@ -298,6 +341,7 @@ class MockArgsToProtobufConverter extends _i1.Mock ), ), ) as _i2.DisconnectFromDeviceRequest); + @override _i2.ReadCharacteristicRequest createReadCharacteristicRequest( _i3.CharacteristicInstance? characteristic) => @@ -306,7 +350,7 @@ class MockArgsToProtobufConverter extends _i1.Mock #createReadCharacteristicRequest, [characteristic], ), - returnValue: _FakeReadCharacteristicRequest_2( + returnValue: _FakeReadCharacteristicRequest_3( this, Invocation.method( #createReadCharacteristicRequest, @@ -314,6 +358,7 @@ class MockArgsToProtobufConverter extends _i1.Mock ), ), ) as _i2.ReadCharacteristicRequest); + @override _i2.WriteCharacteristicRequest createWriteCharacteristicRequest( _i3.CharacteristicInstance? characteristic, @@ -327,7 +372,7 @@ class MockArgsToProtobufConverter extends _i1.Mock value, ], ), - returnValue: _FakeWriteCharacteristicRequest_3( + returnValue: _FakeWriteCharacteristicRequest_4( this, Invocation.method( #createWriteCharacteristicRequest, @@ -338,6 +383,7 @@ class MockArgsToProtobufConverter extends _i1.Mock ), ), ) as _i2.WriteCharacteristicRequest); + @override _i2.NotifyCharacteristicRequest createNotifyCharacteristicRequest( _i3.CharacteristicInstance? characteristic) => @@ -346,7 +392,7 @@ class MockArgsToProtobufConverter extends _i1.Mock #createNotifyCharacteristicRequest, [characteristic], ), - returnValue: _FakeNotifyCharacteristicRequest_4( + returnValue: _FakeNotifyCharacteristicRequest_5( this, Invocation.method( #createNotifyCharacteristicRequest, @@ -354,6 +400,7 @@ class MockArgsToProtobufConverter extends _i1.Mock ), ), ) as _i2.NotifyCharacteristicRequest); + @override _i2.NotifyNoMoreCharacteristicRequest createNotifyNoMoreCharacteristicRequest( _i3.CharacteristicInstance? characteristic) => @@ -362,7 +409,7 @@ class MockArgsToProtobufConverter extends _i1.Mock #createNotifyNoMoreCharacteristicRequest, [characteristic], ), - returnValue: _FakeNotifyNoMoreCharacteristicRequest_5( + returnValue: _FakeNotifyNoMoreCharacteristicRequest_6( this, Invocation.method( #createNotifyNoMoreCharacteristicRequest, @@ -370,6 +417,7 @@ class MockArgsToProtobufConverter extends _i1.Mock ), ), ) as _i2.NotifyNoMoreCharacteristicRequest); + @override _i2.NegotiateMtuRequest createNegotiateMtuRequest( String? deviceId, @@ -383,7 +431,7 @@ class MockArgsToProtobufConverter extends _i1.Mock mtu, ], ), - returnValue: _FakeNegotiateMtuRequest_6( + returnValue: _FakeNegotiateMtuRequest_7( this, Invocation.method( #createNegotiateMtuRequest, @@ -394,6 +442,7 @@ class MockArgsToProtobufConverter extends _i1.Mock ), ), ) as _i2.NegotiateMtuRequest); + @override _i2.ChangeConnectionPriorityRequest createChangeConnectionPrioRequest( String? deviceId, @@ -407,7 +456,7 @@ class MockArgsToProtobufConverter extends _i1.Mock priority, ], ), - returnValue: _FakeChangeConnectionPriorityRequest_7( + returnValue: _FakeChangeConnectionPriorityRequest_8( this, Invocation.method( #createChangeConnectionPrioRequest, @@ -418,6 +467,7 @@ class MockArgsToProtobufConverter extends _i1.Mock ), ), ) as _i2.ChangeConnectionPriorityRequest); + @override _i2.ScanForDevicesRequest createScanForDevicesRequest({ required List<_i3.Uuid>? withServices, @@ -434,7 +484,7 @@ class MockArgsToProtobufConverter extends _i1.Mock #requireLocationServicesEnabled: requireLocationServicesEnabled, }, ), - returnValue: _FakeScanForDevicesRequest_8( + returnValue: _FakeScanForDevicesRequest_9( this, Invocation.method( #createScanForDevicesRequest, @@ -447,6 +497,7 @@ class MockArgsToProtobufConverter extends _i1.Mock ), ), ) as _i2.ScanForDevicesRequest); + @override _i2.ClearGattCacheRequest createClearGattCacheRequest(String? deviceId) => (super.noSuchMethod( @@ -454,7 +505,7 @@ class MockArgsToProtobufConverter extends _i1.Mock #createClearGattCacheRequest, [deviceId], ), - returnValue: _FakeClearGattCacheRequest_9( + returnValue: _FakeClearGattCacheRequest_10( this, Invocation.method( #createClearGattCacheRequest, @@ -462,6 +513,7 @@ class MockArgsToProtobufConverter extends _i1.Mock ), ), ) as _i2.ClearGattCacheRequest); + @override _i2.DiscoverServicesRequest createDiscoverServicesRequest(String? deviceId) => (super.noSuchMethod( @@ -469,7 +521,7 @@ class MockArgsToProtobufConverter extends _i1.Mock #createDiscoverServicesRequest, [deviceId], ), - returnValue: _FakeDiscoverServicesRequest_10( + returnValue: _FakeDiscoverServicesRequest_11( this, Invocation.method( #createDiscoverServicesRequest, @@ -477,6 +529,7 @@ class MockArgsToProtobufConverter extends _i1.Mock ), ), ) as _i2.DiscoverServicesRequest); + @override _i2.ReadRssiRequest createReadRssiRequest(String? deviceId) => (super.noSuchMethod( @@ -484,7 +537,7 @@ class MockArgsToProtobufConverter extends _i1.Mock #createReadRssiRequest, [deviceId], ), - returnValue: _FakeReadRssiRequest_11( + returnValue: _FakeReadRssiRequest_12( this, Invocation.method( #createReadRssiRequest, @@ -510,13 +563,14 @@ class MockProtobufConverter extends _i1.Mock implements _i7.ProtobufConverter { ), returnValue: _i3.BleStatus.unknown, ) as _i3.BleStatus); + @override _i3.ScanResult scanResultFrom(List? data) => (super.noSuchMethod( Invocation.method( #scanResultFrom, [data], ), - returnValue: _FakeScanResult_12( + returnValue: _FakeScanResult_13( this, Invocation.method( #scanResultFrom, @@ -524,6 +578,22 @@ class MockProtobufConverter extends _i1.Mock implements _i7.ProtobufConverter { ), ), ) as _i3.ScanResult); + + @override + _i3.BondStateUpdate bondUpdateFrom(List? data) => (super.noSuchMethod( + Invocation.method( + #bondUpdateFrom, + [data], + ), + returnValue: _FakeBondStateUpdate_14( + this, + Invocation.method( + #bondUpdateFrom, + [data], + ), + ), + ) as _i3.BondStateUpdate); + @override _i3.ConnectionStateUpdate connectionStateUpdateFrom(List? data) => (super.noSuchMethod( @@ -531,7 +601,7 @@ class MockProtobufConverter extends _i1.Mock implements _i7.ProtobufConverter { #connectionStateUpdateFrom, [data], ), - returnValue: _FakeConnectionStateUpdate_13( + returnValue: _FakeConnectionStateUpdate_15( this, Invocation.method( #connectionStateUpdateFrom, @@ -539,6 +609,17 @@ class MockProtobufConverter extends _i1.Mock implements _i7.ProtobufConverter { ), ), ) as _i3.ConnectionStateUpdate); + + @override + List<_i3.RestoredPeripheral> restoredDevicesFrom(List? data) => + (super.noSuchMethod( + Invocation.method( + #restoredDevicesFrom, + [data], + ), + returnValue: <_i3.RestoredPeripheral>[], + ) as List<_i3.RestoredPeripheral>); + @override _i3.Result<_i3.Unit, _i3.GenericFailure<_i3.ClearGattCacheError>?> clearGattCacheResultFrom(List? data) => (super.noSuchMethod( @@ -546,7 +627,7 @@ class MockProtobufConverter extends _i1.Mock implements _i7.ProtobufConverter { #clearGattCacheResultFrom, [data], ), - returnValue: _FakeResult_14<_i3.Unit, + returnValue: _FakeResult_16<_i3.Unit, _i3.GenericFailure<_i3.ClearGattCacheError>?>( this, Invocation.method( @@ -556,6 +637,7 @@ class MockProtobufConverter extends _i1.Mock implements _i7.ProtobufConverter { ), ) as _i3 .Result<_i3.Unit, _i3.GenericFailure<_i3.ClearGattCacheError>?>); + @override _i3.CharacteristicValue characteristicValueFrom(List? data) => (super.noSuchMethod( @@ -563,7 +645,7 @@ class MockProtobufConverter extends _i1.Mock implements _i7.ProtobufConverter { #characteristicValueFrom, [data], ), - returnValue: _FakeCharacteristicValue_15( + returnValue: _FakeCharacteristicValue_17( this, Invocation.method( #characteristicValueFrom, @@ -571,6 +653,7 @@ class MockProtobufConverter extends _i1.Mock implements _i7.ProtobufConverter { ), ), ) as _i3.CharacteristicValue); + @override _i3.WriteCharacteristicInfo writeCharacteristicInfoFrom(List? data) => (super.noSuchMethod( @@ -578,7 +661,7 @@ class MockProtobufConverter extends _i1.Mock implements _i7.ProtobufConverter { #writeCharacteristicInfoFrom, [data], ), - returnValue: _FakeWriteCharacteristicInfo_16( + returnValue: _FakeWriteCharacteristicInfo_18( this, Invocation.method( #writeCharacteristicInfoFrom, @@ -586,6 +669,7 @@ class MockProtobufConverter extends _i1.Mock implements _i7.ProtobufConverter { ), ), ) as _i3.WriteCharacteristicInfo); + @override _i3.ConnectionPriorityInfo connectionPriorityInfoFrom(List? data) => (super.noSuchMethod( @@ -593,7 +677,7 @@ class MockProtobufConverter extends _i1.Mock implements _i7.ProtobufConverter { #connectionPriorityInfoFrom, [data], ), - returnValue: _FakeConnectionPriorityInfo_17( + returnValue: _FakeConnectionPriorityInfo_19( this, Invocation.method( #connectionPriorityInfoFrom, @@ -601,6 +685,7 @@ class MockProtobufConverter extends _i1.Mock implements _i7.ProtobufConverter { ), ), ) as _i3.ConnectionPriorityInfo); + @override int mtuSizeFrom(List? data) => (super.noSuchMethod( Invocation.method( @@ -609,6 +694,7 @@ class MockProtobufConverter extends _i1.Mock implements _i7.ProtobufConverter { ), returnValue: 0, ) as int); + @override List<_i3.DiscoveredService> discoveredServicesFrom(List? data) => (super.noSuchMethod( @@ -618,6 +704,7 @@ class MockProtobufConverter extends _i1.Mock implements _i7.ProtobufConverter { ), returnValue: <_i3.DiscoveredService>[], ) as List<_i3.DiscoveredService>); + @override int readRssiResultFrom(List? data) => (super.noSuchMethod( Invocation.method( @@ -639,26 +726,32 @@ class MockMethodChannel extends _i1.Mock implements _i8.MethodChannel { @override String get name => (super.noSuchMethod( Invocation.getter(#name), - returnValue: '', + returnValue: _i9.dummyValue( + this, + Invocation.getter(#name), + ), ) as String); + @override _i4.MethodCodec get codec => (super.noSuchMethod( Invocation.getter(#codec), - returnValue: _FakeMethodCodec_18( + returnValue: _FakeMethodCodec_20( this, Invocation.getter(#codec), ), ) as _i4.MethodCodec); + @override _i5.BinaryMessenger get binaryMessenger => (super.noSuchMethod( Invocation.getter(#binaryMessenger), - returnValue: _FakeBinaryMessenger_19( + returnValue: _FakeBinaryMessenger_21( this, Invocation.getter(#binaryMessenger), ), ) as _i5.BinaryMessenger); + @override - _i9.Future invokeMethod( + _i10.Future invokeMethod( String? method, [ dynamic arguments, ]) => @@ -670,10 +763,11 @@ class MockMethodChannel extends _i1.Mock implements _i8.MethodChannel { arguments, ], ), - returnValue: _i9.Future.value(), - ) as _i9.Future); + returnValue: _i10.Future.value(), + ) as _i10.Future); + @override - _i9.Future?> invokeListMethod( + _i10.Future?> invokeListMethod( String? method, [ dynamic arguments, ]) => @@ -685,10 +779,11 @@ class MockMethodChannel extends _i1.Mock implements _i8.MethodChannel { arguments, ], ), - returnValue: _i9.Future?>.value(), - ) as _i9.Future?>); + returnValue: _i10.Future?>.value(), + ) as _i10.Future?>); + @override - _i9.Future?> invokeMapMethod( + _i10.Future?> invokeMapMethod( String? method, [ dynamic arguments, ]) => @@ -700,11 +795,12 @@ class MockMethodChannel extends _i1.Mock implements _i8.MethodChannel { arguments, ], ), - returnValue: _i9.Future?>.value(), - ) as _i9.Future?>); + returnValue: _i10.Future?>.value(), + ) as _i10.Future?>); + @override void setMethodCallHandler( - _i9.Future Function(_i4.MethodCall)? handler) => + _i10.Future Function(_i4.MethodCall)? handler) => super.noSuchMethod( Invocation.method( #setMethodCallHandler, diff --git a/packages/reactive_ble_platform_interface/lib/src/model/bond_state_update.dart b/packages/reactive_ble_platform_interface/lib/src/model/bond_state_update.dart new file mode 100644 index 00000000..cf434422 --- /dev/null +++ b/packages/reactive_ble_platform_interface/lib/src/model/bond_state_update.dart @@ -0,0 +1,33 @@ +import 'package:functional_data/functional_data.dart'; +import 'package:meta/meta.dart'; + +part 'bond_state_update.g.dart'; +//ignore_for_file: annotate_overrides + +///Status update for a specific BLE device. +@immutable +@FunctionalData() +class BondStateUpdate extends $BondStateUpdate { + final String deviceId; + final DeviceBondState bondState; + + const BondStateUpdate({ + required this.deviceId, + required this.bondState, + }); +} + +/// Connection status. +enum DeviceBondState { + /// Device is not bonded. + none, + + /// Device bonding is in progress. + bonding, + + /// Device is bonded. + bonded, + + /// Bond state is not (yet) determined. + unknown, +} diff --git a/packages/reactive_ble_platform_interface/lib/src/model/bond_state_update.g.dart b/packages/reactive_ble_platform_interface/lib/src/model/bond_state_update.g.dart new file mode 100644 index 00000000..bd1a32d8 --- /dev/null +++ b/packages/reactive_ble_platform_interface/lib/src/model/bond_state_update.g.dart @@ -0,0 +1,82 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'bond_state_update.dart'; + +// ************************************************************************** +// FunctionalDataGenerator +// ************************************************************************** + +abstract class $BondStateUpdate { + const $BondStateUpdate(); + + String get deviceId; + DeviceBondState get bondState; + + BondStateUpdate copyWith({ + String? deviceId, + DeviceBondState? bondState, + }) => + BondStateUpdate( + deviceId: deviceId ?? this.deviceId, + bondState: bondState ?? this.bondState, + ); + + BondStateUpdate copyUsing( + void Function(BondStateUpdate$Change change) mutator) { + final change = BondStateUpdate$Change._( + this.deviceId, + this.bondState, + ); + mutator(change); + return BondStateUpdate( + deviceId: change.deviceId, + bondState: change.bondState, + ); + } + + @override + String toString() => + "BondStateUpdate(deviceId: $deviceId, bondState: $bondState)"; + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) => + other is BondStateUpdate && + other.runtimeType == runtimeType && + deviceId == other.deviceId && + bondState == other.bondState; + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode { + var result = 17; + result = 37 * result + deviceId.hashCode; + result = 37 * result + bondState.hashCode; + return result; + } +} + +class BondStateUpdate$Change { + BondStateUpdate$Change._( + this.deviceId, + this.bondState, + ); + + String deviceId; + DeviceBondState bondState; +} + +// ignore: avoid_classes_with_only_static_members +class BondStateUpdate$ { + static final deviceId = Lens( + (deviceIdContainer) => deviceIdContainer.deviceId, + (deviceIdContainer, deviceId) => + deviceIdContainer.copyWith(deviceId: deviceId), + ); + + static final bondState = Lens( + (bondStateContainer) => bondStateContainer.bondState, + (bondStateContainer, bondState) => + bondStateContainer.copyWith(bondState: bondState), + ); +} diff --git a/packages/reactive_ble_platform_interface/lib/src/model/connection_state_update.dart b/packages/reactive_ble_platform_interface/lib/src/model/connection_state_update.dart index 6ee0ca65..d0c14a5a 100644 --- a/packages/reactive_ble_platform_interface/lib/src/model/connection_state_update.dart +++ b/packages/reactive_ble_platform_interface/lib/src/model/connection_state_update.dart @@ -35,7 +35,7 @@ enum DeviceConnectionState { disconnecting, /// Device is disconnected. - disconnected + disconnected, } /// Type of connection error. diff --git a/packages/reactive_ble_platform_interface/lib/src/model/restored_device.dart b/packages/reactive_ble_platform_interface/lib/src/model/restored_device.dart new file mode 100644 index 00000000..db29a54e --- /dev/null +++ b/packages/reactive_ble_platform_interface/lib/src/model/restored_device.dart @@ -0,0 +1,29 @@ +import 'package:collection/collection.dart'; +import 'package:functional_data/functional_data.dart'; +import 'package:meta/meta.dart'; + +import '../../reactive_ble_platform_interface.dart'; + +part 'restored_device.g.dart'; + +// ignore_for_file: annotate_overrides, avoid_classes_with_only_static_members, non_constant_identifier_names + +///Ble device that is restored on initialization. +@immutable +@FunctionalData() +class RestoredDevice extends $RestoredDevice { + final String id; + final String name; + + @CustomEquality(DeepCollectionEquality()) + final Map>> characteristicStreams; + + final Stream connectionStream; + + const RestoredDevice({ + required this.id, + required this.name, + required this.characteristicStreams, + required this.connectionStream, + }); +} diff --git a/packages/reactive_ble_platform_interface/lib/src/model/restored_device.g.dart b/packages/reactive_ble_platform_interface/lib/src/model/restored_device.g.dart new file mode 100644 index 00000000..a54677ee --- /dev/null +++ b/packages/reactive_ble_platform_interface/lib/src/model/restored_device.g.dart @@ -0,0 +1,117 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'restored_device.dart'; + +// ************************************************************************** +// FunctionalDataGenerator +// ************************************************************************** + +abstract class $RestoredDevice { + const $RestoredDevice(); + + String get id; + String get name; + Map>> get characteristicStreams; + Stream get connectionStream; + + RestoredDevice copyWith({ + String? id, + String? name, + Map>>? characteristicStreams, + Stream? connectionStream, + }) => + RestoredDevice( + id: id ?? this.id, + name: name ?? this.name, + characteristicStreams: + characteristicStreams ?? this.characteristicStreams, + connectionStream: connectionStream ?? this.connectionStream, + ); + + RestoredDevice copyUsing( + void Function(RestoredDevice$Change change) mutator) { + final change = RestoredDevice$Change._( + this.id, + this.name, + this.characteristicStreams, + this.connectionStream, + ); + mutator(change); + return RestoredDevice( + id: change.id, + name: change.name, + characteristicStreams: change.characteristicStreams, + connectionStream: change.connectionStream, + ); + } + + @override + String toString() => + "RestoredDevice(id: $id, name: $name, characteristicStreams: $characteristicStreams, connectionStream: $connectionStream)"; + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) => + other is RestoredDevice && + other.runtimeType == runtimeType && + id == other.id && + name == other.name && + const DeepCollectionEquality() + .equals(characteristicStreams, other.characteristicStreams) && + connectionStream == other.connectionStream; + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode { + var result = 17; + result = 37 * result + id.hashCode; + result = 37 * result + name.hashCode; + result = 37 * result + + const DeepCollectionEquality().hash(characteristicStreams); + result = 37 * result + connectionStream.hashCode; + return result; + } +} + +class RestoredDevice$Change { + RestoredDevice$Change._( + this.id, + this.name, + this.characteristicStreams, + this.connectionStream, + ); + + String id; + String name; + Map>> characteristicStreams; + Stream connectionStream; +} + +// ignore: avoid_classes_with_only_static_members +class RestoredDevice$ { + static final id = Lens( + (idContainer) => idContainer.id, + (idContainer, id) => idContainer.copyWith(id: id), + ); + + static final name = Lens( + (nameContainer) => nameContainer.name, + (nameContainer, name) => nameContainer.copyWith(name: name), + ); + + static final characteristicStreams = + Lens>>>( + (characteristicStreamsContainer) => + characteristicStreamsContainer.characteristicStreams, + (characteristicStreamsContainer, characteristicStreams) => + characteristicStreamsContainer.copyWith( + characteristicStreams: characteristicStreams), + ); + + static final connectionStream = + Lens>( + (connectionStreamContainer) => connectionStreamContainer.connectionStream, + (connectionStreamContainer, connectionStream) => + connectionStreamContainer.copyWith(connectionStream: connectionStream), + ); +} diff --git a/packages/reactive_ble_platform_interface/lib/src/model/restored_peripheral.dart b/packages/reactive_ble_platform_interface/lib/src/model/restored_peripheral.dart new file mode 100644 index 00000000..313ba915 --- /dev/null +++ b/packages/reactive_ble_platform_interface/lib/src/model/restored_peripheral.dart @@ -0,0 +1,26 @@ +import 'package:collection/collection.dart'; +import 'package:functional_data/functional_data.dart'; +import 'package:meta/meta.dart'; + +import '../../reactive_ble_platform_interface.dart'; + +part 'restored_peripheral.g.dart'; + +// ignore_for_file: annotate_overrides, avoid_classes_with_only_static_members, non_constant_identifier_names + +///Ble device that is restored on initialization. +@immutable +@FunctionalData() +class RestoredPeripheral extends $RestoredPeripheral { + final String id; + final String name; + + @CustomEquality(DeepCollectionEquality()) + final List subscriptions; + + const RestoredPeripheral({ + required this.id, + required this.name, + required this.subscriptions, + }); +} diff --git a/packages/reactive_ble_platform_interface/lib/src/model/restored_peripheral.g.dart b/packages/reactive_ble_platform_interface/lib/src/model/restored_peripheral.g.dart new file mode 100644 index 00000000..7fd0c4e1 --- /dev/null +++ b/packages/reactive_ble_platform_interface/lib/src/model/restored_peripheral.g.dart @@ -0,0 +1,96 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'restored_peripheral.dart'; + +// ************************************************************************** +// FunctionalDataGenerator +// ************************************************************************** + +abstract class $RestoredPeripheral { + const $RestoredPeripheral(); + + String get id; + String get name; + List get subscriptions; + + RestoredPeripheral copyWith({ + String? id, + String? name, + List? subscriptions, + }) => + RestoredPeripheral( + id: id ?? this.id, + name: name ?? this.name, + subscriptions: subscriptions ?? this.subscriptions, + ); + + RestoredPeripheral copyUsing( + void Function(RestoredPeripheral$Change change) mutator) { + final change = RestoredPeripheral$Change._( + this.id, + this.name, + this.subscriptions, + ); + mutator(change); + return RestoredPeripheral( + id: change.id, + name: change.name, + subscriptions: change.subscriptions, + ); + } + + @override + String toString() => + "RestoredPeripheral(id: $id, name: $name, subscriptions: $subscriptions)"; + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) => + other is RestoredPeripheral && + other.runtimeType == runtimeType && + id == other.id && + name == other.name && + const DeepCollectionEquality().equals(subscriptions, other.subscriptions); + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode { + var result = 17; + result = 37 * result + id.hashCode; + result = 37 * result + name.hashCode; + result = 37 * result + const DeepCollectionEquality().hash(subscriptions); + return result; + } +} + +class RestoredPeripheral$Change { + RestoredPeripheral$Change._( + this.id, + this.name, + this.subscriptions, + ); + + String id; + String name; + List subscriptions; +} + +// ignore: avoid_classes_with_only_static_members +class RestoredPeripheral$ { + static final id = Lens( + (idContainer) => idContainer.id, + (idContainer, id) => idContainer.copyWith(id: id), + ); + + static final name = Lens( + (nameContainer) => nameContainer.name, + (nameContainer, name) => nameContainer.copyWith(name: name), + ); + + static final subscriptions = + Lens>( + (subscriptionsContainer) => subscriptionsContainer.subscriptions, + (subscriptionsContainer, subscriptions) => + subscriptionsContainer.copyWith(subscriptions: subscriptions), + ); +} diff --git a/packages/reactive_ble_platform_interface/lib/src/models.dart b/packages/reactive_ble_platform_interface/lib/src/models.dart index e86bb64a..eb7de300 100644 --- a/packages/reactive_ble_platform_interface/lib/src/models.dart +++ b/packages/reactive_ble_platform_interface/lib/src/models.dart @@ -1,4 +1,5 @@ export './model/ble_status.dart'; +export './model/bond_state_update.dart'; export './model/characteristic_instance.dart'; export './model/characteristic_value.dart'; export './model/clear_gatt_cache_error.dart'; @@ -10,6 +11,8 @@ export './model/discovered_service.dart'; export './model/generic_failure.dart'; export './model/log_level.dart'; export './model/qualified_characteristic.dart'; +export './model/restored_device.dart'; +export './model/restored_peripheral.dart'; export './model/result.dart'; export './model/scan_mode.dart'; export './model/scan_session.dart'; diff --git a/packages/reactive_ble_platform_interface/lib/src/reactive_ble_platform_interface.dart b/packages/reactive_ble_platform_interface/lib/src/reactive_ble_platform_interface.dart index 6c620641..e4a3c3a4 100644 --- a/packages/reactive_ble_platform_interface/lib/src/reactive_ble_platform_interface.dart +++ b/packages/reactive_ble_platform_interface/lib/src/reactive_ble_platform_interface.dart @@ -24,6 +24,14 @@ abstract class ReactiveBlePlatform extends PlatformInterface { _instance = instance; } + /// Stream that provides status updates regarding device bonding. + /// + /// It is important to subscribe to this stream before connecting to a device + /// since it can happen that some results are missed. + Stream get bondUpdateStream { + throw UnimplementedError('scanStream has not been implemented.'); + } + /// Stream providing ble scan results. /// /// It is important to subscribe to this stream before scanning for devices @@ -49,6 +57,14 @@ abstract class ReactiveBlePlatform extends PlatformInterface { throw UnimplementedError('connectionStream has not been implemented.'); } + /// Listen to this stream to get devices restored on initialization. + /// + /// It is important to subscribe to this stream before calling [initialize] + /// since it can happen that some results are missed. + Stream get restoredDeviceStream { + throw UnimplementedError('restoreDeviceStream has not been implemented.'); + } + /// Stream that provides value updates about the characteristics that are read /// or subscribed to. Stream get charValueUpdateStream { diff --git a/packages/reactive_ble_platform_interface/pubspec.lock b/packages/reactive_ble_platform_interface/pubspec.lock index 971ee206..be1f2819 100644 --- a/packages/reactive_ble_platform_interface/pubspec.lock +++ b/packages/reactive_ble_platform_interface/pubspec.lock @@ -295,26 +295,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" url: "https://pub.dev" source: hosted - version: "10.0.0" + version: "10.0.5" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.5" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.1" lints: dependency: transitive description: @@ -343,18 +343,18 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec url: "https://pub.dev" source: hosted - version: "0.8.0" + version: "0.11.1" meta: dependency: "direct main" description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.15.0" mime: dependency: transitive description: @@ -500,10 +500,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.2" timing: dependency: transitive description: @@ -532,10 +532,10 @@ packages: dependency: transitive description: name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "13.0.0" + version: "14.2.5" watcher: dependency: transitive description: @@ -570,4 +570,4 @@ packages: version: "3.1.2" sdks: dart: ">=3.3.0 <4.0.0" - flutter: ">=2.0.0" + flutter: ">=3.18.0-18.0.pre.54"