/** * Requests the new connection priority. Acceptable values are: * <ol> * <li>{@link ConnectionPriorityRequest#CONNECTION_PRIORITY_HIGH} * - Interval: 11.25 -15 ms (Android 6+) and 7.5 - 10 ms (older), latency: 0, * supervision timeout: 20 sec,</li> * <li>{@link ConnectionPriorityRequest#CONNECTION_PRIORITY_BALANCED} * - Interval: 30 - 50 ms, latency: 0, supervision timeout: 20 sec,</li> * <li>{@link ConnectionPriorityRequest#CONNECTION_PRIORITY_LOW_POWER} * - Interval: 100 - 125 ms, latency: 2, supervision timeout: 20 sec.</li> * </ol> * Requesting connection priority is available on Android Lollipop or newer. On older * platforms the request will enqueue, but will fail to execute and {@link #fail(FailCallback)} * callback will be called. * * @param priority one of: {@link ConnectionPriorityRequest#CONNECTION_PRIORITY_HIGH}, * {@link ConnectionPriorityRequest#CONNECTION_PRIORITY_BALANCED}, * {@link ConnectionPriorityRequest#CONNECTION_PRIORITY_LOW_POWER}. * @return The new request. * @deprecated Access to this method will change to package-only. * Use {@link BleManager#requestConnectionPriority(int)} instead. */ @Deprecated @NonNull public static ConnectionPriorityRequest newConnectionPriorityRequest( @ConnectionPriority final int priority) { return new ConnectionPriorityRequest(Type.REQUEST_CONNECTION_PRIORITY, priority); }
/** * Requests the new connection priority. Acceptable values are: * <ol> * <li>{@link BluetoothGatt#CONNECTION_PRIORITY_HIGH} * - Interval: 11.25 -15 ms, latency: 0, supervision timeout: 20 sec,</li> * <li>{@link BluetoothGatt#CONNECTION_PRIORITY_BALANCED} * - Interval: 30 - 50 ms, latency: 0, supervision timeout: 20 sec,</li> * <li>{@link BluetoothGatt#CONNECTION_PRIORITY_LOW_POWER} * - Interval: 100 - 125 ms, latency: 2, supervision timeout: 20 sec.</li> * </ol> * Works only on Android Lollipop or newer. On older system versions will cause * {@link Request#fail(FailCallback)} callback or throw * {@link no.nordicsemi.android.ble.exception.RequestFailedException} with * {@link FailCallback#REASON_REQUEST_FAILED} status if called synchronously. * Starting from Android Oreo you may get a callback with the interval, latency and timeout * using {@link ConnectionPriorityRequest#with(ConnectionPriorityCallback)}. * <p> * The returned request must be either enqueued using {@link Request#enqueue()} for * asynchronous use, or awaited using await() in synchronous execution. * * @param priority one of: {@link BluetoothGatt#CONNECTION_PRIORITY_HIGH}, * {@link BluetoothGatt#CONNECTION_PRIORITY_BALANCED}, * {@link BluetoothGatt#CONNECTION_PRIORITY_LOW_POWER}. * @return The request. */ @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) protected final ConnectionPriorityRequest requestConnectionPriority( @ConnectionPriority final int priority) { return Request.newConnectionPriorityRequest(priority).setManager(this); }