toAddress static method

Future<BluetoothConnection> toAddress(
  1. String? address, {
  2. ConnectionType type = ConnectionType.AUTO,
})

Returns connection to given address.

Implementation

static Future<BluetoothConnection> toAddress(String? address, {ConnectionType type = ConnectionType.AUTO}) async { //DUMMY //THINK Expose bc/ble?
  switch (type) {
    case ConnectionType.AUTO:
      try {
        return await toAddressBC(address);
      } catch (e, s) {
        // Bluetooth classic failed; try BLE
        return toAddressBLE(address);
      }
    case ConnectionType.AUTO_BUT_TRY_BLE_FIRST:
      try {
        return await toAddressBLE(address);
      } catch (e, s) {
        // BLE failed; try bluetooth classic
        return toAddressBC(address);
      }
    case ConnectionType.CLASSIC:
      return toAddressBC(address);
    case ConnectionType.BLE:
      return toAddressBLE(address);
  }
}