public abstract class TimeoutableRequest extends Request
| Modifier and Type | Field and Description |
|---|---|
protected long |
timeout |
handler, requestHandler| Modifier and Type | Method and Description |
|---|---|
void |
await()
Synchronously waits until the request is done.
|
void |
await(long timeout)
Deprecated.
Use
timeout(long) and await() instead. |
void |
enqueue()
Enqueues the request for asynchronous execution.
|
void |
enqueue(long timeout)
Deprecated.
Use
timeout(long) and enqueue() instead. |
TimeoutableRequest |
setHandler(android.os.Handler handler)
Sets the handler that will be used to invoke callbacks.
|
TimeoutableRequest |
timeout(long timeout)
Sets the operation timeout.
|
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@NonNull public TimeoutableRequest setHandler(@NonNull android.os.Handler handler)
RequestBleManager will be used.setHandler in class Requesthandler - The handler to invoke callbacks for this request.@NonNull public TimeoutableRequest timeout(long timeout)
FailCallback.REASON_TIMEOUT.timeout - the request timeout in milliseconds, 0 to disable timeout.java.lang.IllegalStateException - thrown when the request has already been started.java.lang.UnsupportedOperationException - thrown when the timeout is not allowed for this request,
as the callback from the system is required.public final void enqueue()
Use timeout(long) to set the maximum time the manager should wait until the device
is ready. When the timeout occurs, the request will fail with
FailCallback.REASON_TIMEOUT and the device will get disconnected.
@Deprecated public final void enqueue(long timeout)
timeout(long) and enqueue() instead.
When the timeout occurs, the request will fail with FailCallback.REASON_TIMEOUT
and the device will get disconnected.
timeout - the request timeout in milliseconds, 0 to disable timeout. This value will
override one set in timeout(long).public final void await()
throws RequestFailedException,
DeviceDisconnectedException,
BluetoothDisabledException,
InvalidRequestException,
java.lang.InterruptedException
Use timeout(long) to set the maximum time the manager should wait until the request
is ready. When the timeout occurs, the InterruptedException will be thrown.
Callbacks set using Request.done(SuccessCallback) and Request.fail(FailCallback)
will be ignored.
This method may not be called from the main (UI) thread.
RequestFailedException - thrown when the BLE request finished with status other
than BluetoothGatt.GATT_SUCCESS.java.lang.InterruptedException - thrown if the timeout occurred before the request has
finished.java.lang.IllegalStateException - thrown when you try to call this method from the main
(UI) thread.DeviceDisconnectedException - thrown when the device disconnected before the request
was completed.BluetoothDisabledException - thrown when the Bluetooth adapter has been disabled.InvalidRequestException - thrown when the request was called before the device was
connected at least once (unknown device).enqueue()@Deprecated
public final void await(long timeout)
throws RequestFailedException,
java.lang.InterruptedException,
DeviceDisconnectedException,
BluetoothDisabledException,
InvalidRequestException
timeout(long) and await() instead.
When the timeout occurs, the InterruptedException will be thrown.
Callbacks set using Request.done(SuccessCallback) and Request.fail(FailCallback)
will be ignored.
This method may not be called from the main (UI) thread.
timeout - optional timeout in milliseconds, 0 to disable timeout. This will
override the timeout set using timeout(long).RequestFailedException - thrown when the BLE request finished with status other
than BluetoothGatt.GATT_SUCCESS.java.lang.InterruptedException - thrown if the timeout occurred before the request has
finished.java.lang.IllegalStateException - thrown when you try to call this method from the main
(UI) thread.DeviceDisconnectedException - thrown when the device disconnected before the request
was completed.BluetoothDisabledException - thrown when the Bluetooth adapter has been disabled.InvalidRequestException - thrown when the request was called before the device was
connected at least once (unknown device).