-
public final class ReliableWriteRequest extends RequestQueue
This queue performs the operations using Reliable Write, also known as Queued Write, procedure. Before the first operation is executed, the Reliable Write procedure is started. Then, all operations are executed one by one.
Cancellation will cause the Reliable Write procedure to be aborted and all operations shall be discarded on the device side.
-
-
Method Summary
Modifier and Type Method Description ReliableWriteRequestsetHandler(@Nullable() Handler handler)Sets the handler that will be used to invoke callbacks. ReliableWriteRequestdone(@NonNull() SuccessCallback callback)Use to set a completion callback. ReliableWriteRequestfail(@NonNull() FailCallback callback)Use to set a callback that will be called in case the request has failed. ReliableWriteRequestinvalid(@NonNull() InvalidRequestCallback callback)Use to set a callback that will be called in case the request was invalid, for examplecalled before the device was connected.This callback will be ignored if request was executed synchronously, in which casethe error will be returned as an exception. ReliableWriteRequestbefore(@NonNull() BeforeCallback callback)Sets a callback that will be executed before the execution of this operation starts. ReliableWriteRequestthen(@NonNull() AfterCallback callback)Sets a callback that will be executed when the request has been processed, no matterthe request result. ReliableWriteRequesttimeout(@IntRange(from = 0) long timeout)Sets the operation timeout. ReliableWriteRequestadd(@NonNull() Operation operation)Enqueues a new operation. voidabort()Alias for cancel. intsize()Returns number of enqueued operations. -
Methods inherited from class no.nordicsemi.android.ble.RequestQueue
add, before, cancel, done, fail, invalid, isEmpty, setHandler, then, timeout -
Methods inherited from class no.nordicsemi.android.ble.TimeoutableRequest
await, await, enqueue, enqueue, isCancelled, setHandler, timeout -
Methods inherited from class no.nordicsemi.android.ble.Request
before, createBond, done, fail, invalid, newConnectionPriorityRequest, newDisableBatteryLevelNotificationsRequest, newDisableIndicationsRequest, newDisableNotificationsRequest, newEnableBatteryLevelNotificationsRequest, newEnableIndicationsRequest, newEnableNotificationsRequest, newMtuRequest, newReadBatteryLevelRequest, newReadPhyRequest, newReadRequest, newReadRequest, newReadRssiRequest, newRefreshCacheRequest, newSetPreferredPhyRequest, newSleepRequest, newWaitForIndicationRequest, newWaitForNotificationRequest, newWriteRequest, newWriteRequest, newWriteRequest, newWriteRequest, newWriteRequest, newWriteRequest, removeBond, setHandler, then -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
setHandler
@NonNull() ReliableWriteRequest setHandler(@Nullable() Handler handler)
Sets the handler that will be used to invoke callbacks. By default, the handler set in BleManager will be used.
If set to null, the callbacks will be invoked immediately on the BLE looper.
- Parameters:
handler- The handler to invoke callbacks for this request.
-
done
@NonNull() ReliableWriteRequest done(@NonNull() SuccessCallback callback)
Use to set a completion callback. The callback will be invoked when the operation hasfinished successfully unless the request was executed synchronously, in which case thiscallback will be ignored.
- Parameters:
callback- the callback.
-
fail
@NonNull() ReliableWriteRequest fail(@NonNull() FailCallback callback)
Use to set a callback that will be called in case the request has failed.If the target device wasn't set before executing this request(connect was never called), the invalid will be used instead, as the BluetoothDevice is not known.
This callback will be ignored if request was executed synchronously, in which casethe error will be returned as an exception.
- Parameters:
callback- the callback.
-
invalid
@NonNull() ReliableWriteRequest invalid(@NonNull() InvalidRequestCallback callback)
Use to set a callback that will be called in case the request was invalid, for examplecalled before the device was connected.This callback will be ignored if request was executed synchronously, in which casethe error will be returned as an exception.
- Parameters:
callback- the callback.
-
before
@NonNull() ReliableWriteRequest before(@NonNull() BeforeCallback callback)
Sets a callback that will be executed before the execution of this operation starts.
- Parameters:
callback- the callback.
-
then
@NonNull() ReliableWriteRequest then(@NonNull() AfterCallback callback)
Sets a callback that will be executed when the request has been processed, no matterthe request result.
Set done or fail if you need a callbackcalled in a specific situation.
This request will not be called if the BluetoothDevice was not set. Instead, InvalidRequestCallback will be called.
- Parameters:
callback- the callback.
-
timeout
@NonNull() ReliableWriteRequest timeout(@IntRange(from = 0) long timeout)
Sets the operation timeout.When the timeout occurs, the request will fail with REASON_TIMEOUT.
- Parameters:
timeout- the request timeout in milliseconds, 0 to disable timeout.
-
add
@NonNull() ReliableWriteRequest add(@NonNull() Operation operation)
Enqueues a new operation. All operations will be executed sequentially in order they wereadded.
- Parameters:
operation- the new operation to be enqueued.
-
size
int size()
Returns number of enqueued operations.
-
-
-
-