diff --git a/lib/Backend/Bluetooth/bluetooth_manager_plus.dart b/lib/Backend/Bluetooth/bluetooth_manager_plus.dart index d0946336..65f186b2 100644 --- a/lib/Backend/Bluetooth/bluetooth_manager_plus.dart +++ b/lib/Backend/Bluetooth/bluetooth_manager_plus.dart @@ -58,7 +58,6 @@ class initFlutterBluePlus extends _$initFlutterBluePlus { return; } - _onServicesResetStreamSubscription = flutterBluePlus.events.onServicesReset.listen((event) async { _bluetoothPlusLogger.info("${event.device.advName} onServicesReset"); await event.device.discoverServices(); @@ -124,15 +123,16 @@ class _MTUChanged extends _$MTUChanged { statefulDevice?.mtu.value = event.mtu; } } + @Riverpod(keepAlive: true) class _OnDiscoveredServices extends _$OnDiscoveredServices { StreamSubscription? streamSubscription; @override void build() { - streamSubscription = flutterBluePlus.events.onDiscoveredServices.listen(listener,onError: (e, s) => _bluetoothPlusLogger.warning("Unable to discover services: $e", e, s)); + streamSubscription = flutterBluePlus.events.onDiscoveredServices.listen(listener, onError: (e, s) => _bluetoothPlusLogger.warning("Unable to discover services: $e", e, s)); ref.onDispose( - () => streamSubscription?.cancel(), + () => streamSubscription?.cancel(), ); } @@ -141,7 +141,7 @@ class _OnDiscoveredServices extends _$OnDiscoveredServices { //Subscribes to all characteristics for (BluetoothService service in event.services) { BluetoothUartService? bluetoothUartService = uartServices.firstWhereOrNull( - (element) => element.bleDeviceService == service.serviceUuid.str, + (element) => element.bleDeviceService == service.serviceUuid.str, ); if (bluetoothUartService != null) { BaseStatefulDevice? statefulDevice = ref.read(knownDevicesProvider)[event.device.remoteId.str]; @@ -153,6 +153,7 @@ class _OnDiscoveredServices extends _$OnDiscoveredServices { } } } + @Riverpod(keepAlive: true) class _RSSIChanged extends _$RSSIChanged { StreamSubscription? streamSubscription; @@ -161,7 +162,7 @@ class _RSSIChanged extends _$RSSIChanged { void build() { streamSubscription = flutterBluePlus.events.onReadRssi.listen(listener, onError: (e, s) => _bluetoothPlusLogger.warning("Unable to read rssi: $e", e, s)); ref.onDispose( - () => streamSubscription?.cancel(), + () => streamSubscription?.cancel(), ); } @@ -171,6 +172,7 @@ class _RSSIChanged extends _$RSSIChanged { statefulDevice?.rssi.value = event.rssi; } } + @Riverpod(keepAlive: true) class _OnConnectionStateChanged extends _$OnConnectionStateChanged { StreamSubscription? streamSubscription; @@ -179,7 +181,7 @@ class _OnConnectionStateChanged extends _$OnConnectionStateChanged { void build() { streamSubscription = flutterBluePlus.events.onConnectionStateChanged.listen(listener); ref.onDispose( - () => streamSubscription?.cancel(), + () => streamSubscription?.cancel(), ); } @@ -218,7 +220,7 @@ class _OnConnectionStateChanged extends _$OnConnectionStateChanged { if (bluetoothConnectionState == BluetoothConnectionState.connected) { bluetoothDevice.readRssi().catchError((e) => -1).onError( (error, stackTrace) => -1, - ); + ); BaseDeviceDefinition? baseDeviceDefinition = DeviceRegistry.getByName(event.device.advName); if (baseDeviceDefinition == null) { return; @@ -276,7 +278,7 @@ class _OnConnectionStateChanged extends _$OnConnectionStateChanged { _bluetoothPlusLogger.fine('Last gear detected'); // Disable all triggers on last device ref.read(triggerListProvider).where((element) => element.enabled).forEach( - (element) { + (element) { element.enabled = false; }, ); @@ -297,6 +299,7 @@ class _OnConnectionStateChanged extends _$OnConnectionStateChanged { } } } + @Riverpod(keepAlive: true) class _OnCharacteristicReceived extends _$OnCharacteristicReceived { StreamSubscription? streamSubscription; @@ -328,8 +331,8 @@ class _OnCharacteristicReceived extends _$OnCharacteristicReceived { String value = const Utf8Decoder().convert(values); statefulDevice.messageHistory.add(MessageHistoryEntry(type: MessageHistoryType.receive, message: value)); statefulDevice.batteryCharging.value = value == "CHARGE ON"; - } catch (e, s) { - _bluetoothPlusLogger.warning("Unable to read values: $values", e, s); + } catch (e) { + _bluetoothPlusLogger.warning("Unable to read values: $values", e); statefulDevice.messageHistory.add(MessageHistoryEntry(type: MessageHistoryType.receive, message: "Unknown: ${values.toString()}")); return; } @@ -337,8 +340,8 @@ class _OnCharacteristicReceived extends _$OnCharacteristicReceived { String value = ""; try { value = const Utf8Decoder().convert(values); - } catch (e, s) { - _bluetoothPlusLogger.warning("Unable to read values: $values $e", e); + } catch (e) { + _bluetoothPlusLogger.warning("Unable to read values: $values $e"); statefulDevice.messageHistory.add(MessageHistoryEntry(type: MessageHistoryType.receive, message: "Unknown: ${values.toString()}")); return; } @@ -385,7 +388,7 @@ class _OnCharacteristicReceived extends _$OnCharacteristicReceived { } } -@Riverpod(keepAlive: true,dependencies: [initFlutterBluePlus]) +@Riverpod(keepAlive: true, dependencies: [initFlutterBluePlus]) class _KeepGearAwake extends _$KeepGearAwake { StreamSubscription? streamSubscription; diff --git a/lib/Backend/Definitions/Device/device_definition.dart b/lib/Backend/Definitions/Device/device_definition.dart index 86b13867..70537a7f 100644 --- a/lib/Backend/Definitions/Device/device_definition.dart +++ b/lib/Backend/Definitions/Device/device_definition.dart @@ -147,9 +147,9 @@ final List uartServices = const [ ), // TailCoNTROL uuids BluetoothUartService( - bleDeviceService: "19F8ADE2-D0C6-4C0A-912A-30601D9B3060", - bleRxCharacteristic: "5E4D86AC-EF2F-466F-A857-8776D45FFBC2", - bleTxCharacteristic: "567A99D6-A442-4AC0-B676-4993BF95F805", + bleDeviceService: "19f8ade2-d0c6-4c0a-912a-30601d9b3060", + bleRxCharacteristic: "567a99d6-a442-4ac0-b676-4993bf95f805", + bleTxCharacteristic: "5e4d86ac-ef2f-466f-a857-8776d45ffbc2", ), ]; @@ -234,7 +234,7 @@ class BaseStatefulDevice { isTailCoNTROL.value = bluetoothUartService.value == uartServices.firstWhere( - (element) => element.bleDeviceService == "19F8ADE2-D0C6-4C0A-912A-30601D9B3060", + (element) => element.bleDeviceService == "19f8ade2-d0c6-4c0a-912a-30601d9b3060", ) ? tailControlStatus.tailControl : tailControlStatus.legacy; diff --git a/lib/Backend/device_registry.dart b/lib/Backend/device_registry.dart index 8d909f81..64751975 100644 --- a/lib/Backend/device_registry.dart +++ b/lib/Backend/device_registry.dart @@ -32,7 +32,7 @@ class DeviceRegistry { uuid: "5fb21175-fef4-448a-a38b-c472d935abab", btName: "minitail", deviceType: DeviceType.miniTail, - fwURL: "https://thetailcompany.com/fw/mini", + fwURL: "https://thetailcompany.com/fw/mini.json", minVersion: Version(major: 5, minor: 0, patch: 0), ), BaseDeviceDefinition( diff --git a/pubspec.lock b/pubspec.lock index 7d5e21a2..6578f0cd 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -554,12 +554,11 @@ packages: file_picker: dependency: "direct main" description: - path: "." - ref: "3b299bb0cf7f553a150f9074168e9a53155d2a51" - resolved-ref: "3b299bb0cf7f553a150f9074168e9a53155d2a51" - url: "https://github.com/abdelaziz-mahdy/flutter_file_picker" - source: git - version: "8.1.6" + name: file_picker + sha256: "16dc141db5a2ccc6520ebb6a2eb5945b1b09e95085c021d9f914f8ded7f1465c" + url: "https://pub.dev" + source: hosted + version: "8.1.4" firebase_app_installations: dependency: "direct main" description: @@ -1025,10 +1024,10 @@ packages: dependency: transitive description: name: image - sha256: "599d08e369969bdf83138f5b4e0a7e823d3f992f23b8a64dd626877c37013533" + sha256: "20842a5ad1555be624c314b0c0cc0566e8ece412f61e859a42efeb6d4101a26c" url: "https://pub.dev" source: hosted - version: "4.4.0" + version: "4.5.0" image_size_getter: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index b5aa5b82..0c451e45 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -33,7 +33,7 @@ dependencies: # Platform Interfaces device_info_plus: ^11.2.0 wakelock_plus: ^1.2.8 # Keeps the screen awake - file_picker: ^8.1.5 # used to manually select firmware file + file_picker: 8.1.4 # used to manually select firmware file path_provider: ^2.1.5 # used to get paths for app storage and cache storage package_info_plus: ^8.1.2 permission_handler: ^11.3.1 @@ -150,10 +150,6 @@ dev_dependencies: dependency_overrides: collection: 1.19.1 - file_picker: - git: - url: https://github.com/abdelaziz-mahdy/flutter_file_picker - ref: 3b299bb0cf7f553a150f9074168e9a53155d2a51 #analyzer: 6.7.0 flutter: