bluetoothReconnectDevice method

  1. @override
Future bluetoothReconnectDevice()
override

reconnect using already connected bluetooth device

Implementation

@override
Future<dynamic> bluetoothReconnectDevice() async {
  BluetoothDevice? lastDevice =
      await DtbLinkStorage.instance.lastConnectedDevice;
  if (lastDevice != null) {
    btCtr = Completer();
    methodChannel.invokeMethod(
      "bluetooth.connect_device",
      {"device_id": lastDevice.deviceId},
    );
    Map<String, dynamic> ret = await btCtr?.future;
    if (ret["code"] == 0) {
      ret.putIfAbsent("last_device", () => lastDevice.toJson());
    }
    return json.encode(ret.toString());
  }
  return null;
}