bluetoothReconnectDevice method

  1. @override
Future<BluetoothDevice?> bluetoothReconnectDevice()
override

reconnect using already connected bluetooth device

Implementation

@override
Future<BluetoothDevice?> bluetoothReconnectDevice() async {
  BluetoothDevice? lastDevice =
      await DtbLinkStorage.instance.lastConnectedDevice;
  if (lastDevice != null) {
    btCtr = Completer();
    methodChannel.invokeMethod(
      "bluetooth.connect_device",
      {"device_id": lastDevice.deviceId},
    );
    int? ret = await btCtr?.future;
    if (ret == 0) {
      return lastDevice;
    }
  }
  return null;
}