restoreWithMac static method
Restore Connection With Mac address on android
Implementation
static Future<BluetoothDevice?> restoreWithMac({
required String deviceName,
required String macAddress,
}) async {
if (!Platform.isAndroid) return null;
var request = protos.ConnectRequest.create()
..remoteId = macAddress
..androidAutoConnect = false;
await FlutterBlue.instance._channel
.invokeMethod('connect', request.writeToBuffer());
final device = BluetoothDevice._(
id: DeviceIdentifier(macAddress),
name: deviceName,
type: BluetoothDeviceType.le,
);
await device.state.firstWhere((s) => s == BluetoothDeviceState.connected);
return device;
}