From c417a0cec88da197def39d2520ea02e3de709ccc Mon Sep 17 00:00:00 2001 From: Codel1417 Date: Sat, 23 Nov 2024 23:25:26 -0500 Subject: [PATCH] handle read rssi errors --- lib/Backend/Bluetooth/bluetooth_manager_plus.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Backend/Bluetooth/bluetooth_manager_plus.dart b/lib/Backend/Bluetooth/bluetooth_manager_plus.dart index 526fbb10..bdc294da 100644 --- a/lib/Backend/Bluetooth/bluetooth_manager_plus.dart +++ b/lib/Backend/Bluetooth/bluetooth_manager_plus.dart @@ -97,7 +97,9 @@ Future initFlutterBluePlus(InitFlutterBluePlusRef ref) async { //transaction.setTag('Device Name', device.name); statefulDevice.deviceConnectionState.value = event.connectionState == BluetoothConnectionState.connected ? ConnectivityState.connected : ConnectivityState.disconnected; if (bluetoothConnectionState == BluetoothConnectionState.connected) { - bluetoothDevice.readRssi(); + bluetoothDevice.readRssi().catchError((e) => -1).onError( + (error, stackTrace) => -1, + ); BaseDeviceDefinition? baseDeviceDefinition = DeviceRegistry.getByName(event.device.advName); if (baseDeviceDefinition == null) { return; @@ -312,7 +314,10 @@ Future initFlutterBluePlus(InitFlutterBluePlusRef ref) async { if (device != null) { device.commandQueue.addCommand(BluetoothMessage(message: "PING", device: device, priority: Priority.low, type: CommandType.system, timestamp: DateTime.now())); device.commandQueue.addCommand(BluetoothMessage(message: "BATT", device: device, priority: Priority.low, type: CommandType.system, timestamp: DateTime.now())); - element.readRssi(); + element.readRssi().catchError((e) => -1).onError( + (error, stackTrace) => -1, + ); + if (device.baseDeviceDefinition.deviceType != DeviceType.ears && device.hasGlowtip.value == GlowtipStatus.unknown) { device.commandQueue.addCommand(BluetoothMessage(message: "VER", device: device, priority: Priority.low, type: CommandType.system, timestamp: DateTime.now())); }