Skip to content

Commit

Permalink
handle read rssi errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Nov 24, 2024
1 parent c55e83c commit c417a0c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/Backend/Bluetooth/bluetooth_manager_plus.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ Future<void> 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;
Expand Down Expand Up @@ -312,7 +314,10 @@ Future<void> 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()));
}
Expand Down

0 comments on commit c417a0c

Please sign in to comment.