disconnect method

Future<void> disconnect({
  1. int timeout = 35,
  2. bool queue = true,
})
override

Cancels connection to the Bluetooth Device

  • queue If true, this disconnect request will be executed after all other operations complete. If false, this disconnect request will be executed right now, i.e. skipping to the front of the fbp operation queue, which is useful to cancel an in-progress connection attempt.

Implementation

Future<void> disconnect({
  int timeout = 35, // TODO: implementation missing
  bool queue = true, // TODO: implementation missing
}) async {
  try {
    // TODO: bug in WinBle; devices once paired are never connected unless the bonding is removed
    // await WinBle.unPair(_address);
    await WinBle.disconnect(_address);
  } catch (e) {
    print(e);
  } finally {
    FlutterBluePlusWindows._deviceSet.remove(this);
    // FlutterBluePlusWindows._removed.add(this);

    FlutterBluePlusWindows._lastChrs[remoteId]?.clear();
    FlutterBluePlusWindows._isNotifying[remoteId]?.clear();
  }
}