connectDevice method
Implementation
@override
Future<BluetoothDevice?> connectDevice(BluetoothDevice? device) async {
try {
final res =
await bltMethodChannel.invokeMethod('connectDevice', device?.id);
return (res is bool? && res == true)
? device?.copy(bondState: BondState.bonded)
: device?.copy(bondState: BondState.none);
} on PlatformException catch (e) {
if (e.code == 'BluetoothException') {
throw BluetoothException(e.message);
}
throw Exception(e.message);
}
}