diff --git a/lib/Backend/Bluetooth/bluetooth_manager_plus.dart b/lib/Backend/Bluetooth/bluetooth_manager_plus.dart index 2995087e..5e1b1ff6 100644 --- a/lib/Backend/Bluetooth/bluetooth_manager_plus.dart +++ b/lib/Backend/Bluetooth/bluetooth_manager_plus.dart @@ -180,12 +180,12 @@ Future initFlutterBluePlus(InitFlutterBluePlusRef ref) async { _bluetoothPlusLogger.info('${event.device.advName} RSSI:${event.rssi}'); BaseStatefulDevice? statefulDevice = ref.read(knownDevicesProvider)[event.device.remoteId.str]; statefulDevice?.rssi.value = event.rssi; - }); + }, onError: (e, s) => _bluetoothPlusLogger.warning("Unable to read rssi: $e", e, s)); _onMtuChanged = flutterBluePlus.events.onMtuChanged.listen((event) { _bluetoothPlusLogger.info('${event.device.advName} MTU:${event.mtu}'); BaseStatefulDevice? statefulDevice = ref.read(knownDevicesProvider)[event.device.remoteId.str]; statefulDevice?.mtu.value = event.mtu; - }); + }, onError: (e, s) => _bluetoothPlusLogger.warning("Unable to read mtu: $e", e, s)); _onDiscoveredServicesStreamSubscription = flutterBluePlus.events.onDiscoveredServices.listen((event) async { //_bluetoothPlusLogger.info('${event.device} ${event.services}'); //Subscribes to all characteristics @@ -194,7 +194,7 @@ Future initFlutterBluePlus(InitFlutterBluePlusRef ref) async { await characteristic.setNotifyValue(true); } } - }); + }, onError: (e, s) => _bluetoothPlusLogger.warning("Unable to discover services: $e", e, s)); _onCharacteristicReceivedStreamSubscription = flutterBluePlus.events.onCharacteristicReceived.listen((event) async { _bluetoothPlusLogger.info('onCharacteristicReceived ${event.device.advName} ${event.characteristic.uuid.str} ${event.value}'); @@ -408,9 +408,10 @@ Future sendMessage(BaseStatefulDevice device, List message, {bool wit return; } - Future future = bluetoothCharacteristic.write(message, withoutResponse: withoutResponse && bluetoothCharacteristic.properties.writeWithoutResponse).catchError((e) { - _bluetoothPlusLogger.severe("Unable to send message to ${device.baseDeviceDefinition.btName} $e", e); - }); + Future future = bluetoothCharacteristic + .write(message, withoutResponse: withoutResponse && bluetoothCharacteristic.properties.writeWithoutResponse) + .catchError((e) => _bluetoothPlusLogger.warning("Unable to send message to ${device.baseDeviceDefinition.btName} $e", e)) + .onError((e, s) => _bluetoothPlusLogger.severe("Unable to send message to ${device.baseDeviceDefinition.btName} $e", e)); await future; } } diff --git a/lib/Backend/Definitions/Device/device_definition.dart b/lib/Backend/Definitions/Device/device_definition.dart index 859adf78..74630f65 100644 --- a/lib/Backend/Definitions/Device/device_definition.dart +++ b/lib/Backend/Definitions/Device/device_definition.dart @@ -260,6 +260,7 @@ class CommandQueue { StreamSubscription? messageQueueStreamSubscription; void addCommand(BluetoothMessage bluetoothMessage) { + bluetoothLog.info("Adding commands to queue $bluetoothMessage"); if (device.deviceConnectionState.value != ConnectivityState.connected || device.baseStoredDevice.btMACAddress.startsWith("DEV")) { device.deviceState.value = DeviceState.standby; //Mainly for dev gear. Marks the gear as being idle return;