connect method
Connect to a Bluetooth device via address.
isBLE
Whether this is a BLE device. In iOS, this is ignored cause we only support BLE for iOS.
timeout
The timeout for BLE connection. For non-BLE connection, this is ignored.
Throw BTException if failed.
Implementation
@override
Future<bool> connect(
{required String address, bool isBLE = true, Duration timeout = const Duration(seconds: 7)}) async {
try {
if (Platform.isIOS) {
_isBLE = true;
} else {
_isBLE = isBLE;
}
Map<String, dynamic> args = {"address": address, "isBLE": _isBLE, "timeout": timeout.inMilliseconds};
return await methodChannel.invokeMethod("connect", args);
} on PlatformException catch (e) {
throw BTException.fromPlatform(e);
}
}