requestConnectionPriority method

Future<void> requestConnectionPriority({
  1. required ConnectionPriority connectionPriorityRequest,
})

Request connection priority update (Android only)

Implementation

Future<void> requestConnectionPriority(
    {required ConnectionPriority connectionPriorityRequest}) async {
  // check android
  if (Platform.isAndroid == false) {
    throw FlutterBluePlusException(
        ErrorPlatform.fbp,
        "requestConnectionPriority",
        FbpErrorCode.androidOnly.index,
        "android-only");
  }

  // check connected
  if (isDisconnected) {
    throw FlutterBluePlusException(
        ErrorPlatform.fbp,
        "requestConnectionPriority",
        FbpErrorCode.deviceIsDisconnected.index,
        "device is not connected");
  }

  var request = BmConnectionPriorityRequest(
    remoteId: remoteId,
    connectionPriority: _bmFromConnectionPriority(connectionPriorityRequest),
  );

  // invoke
  await FlutterBluePlus._invokeMethod(
      'requestConnectionPriority', request.toMap());
}