public final class WaitForValueChangedRequest extends AwaitingRequest<DataReceivedCallback> implements Operation
timeouthandler, requestHandler| Modifier and Type | Method and Description |
|---|---|
<E extends ProfileReadResponse> |
awaitValid(java.lang.Class<E> responseClass)
Similar to
#await(DataReceivedCallback), but if the response class extends
ProfileReadResponse and the received response is invalid, an exception is thrown. |
<E extends ProfileReadResponse> |
awaitValid(java.lang.Class<E> responseClass,
long timeout)
Deprecated.
Use
timeout(long) and awaitValid(Class) instead. |
<E extends ProfileReadResponse> |
awaitValid(E response)
Similar to
TimeoutableValueRequest.await(Class), but if the response class extends
ProfileReadResponse and the received response is invalid, an exception is thrown. |
<E extends ProfileReadResponse> |
awaitValid(E response,
long timeout)
Deprecated.
Use
timeout(long) and #awaitValid(E) instead. |
WaitForValueChangedRequest |
before(BeforeCallback callback)
Sets a callback that will be executed before the execution of this operation starts.
|
WaitForValueChangedRequest |
done(SuccessCallback callback)
Use to set a completion callback.
|
WaitForValueChangedRequest |
fail(FailCallback callback)
Use to set a callback that will be called in case the request has failed.
|
WaitForValueChangedRequest |
filter(DataFilter filter)
Sets a filter which allows to skip some incoming data.
|
WaitForValueChangedRequest |
invalid(InvalidRequestCallback callback)
Use to set a callback that will be called in case the request was invalid, for example
called before the device was connected.
|
WaitForValueChangedRequest |
merge(DataMerger merger)
Adds a merger that will be used to merge multiple packets into a single Data.
|
WaitForValueChangedRequest |
merge(DataMerger merger,
ReadProgressCallback callback)
Adds a merger that will be used to merge multiple packets into a single Data.
|
WaitForValueChangedRequest |
setHandler(android.os.Handler handler)
Sets the handler that will be used to invoke callbacks.
|
WaitForValueChangedRequest |
timeout(long timeout)
Sets the operation timeout.
|
WaitForValueChangedRequest |
trigger(Operation trigger)
Sets an optional request that is suppose to trigger the notification or indication.
|
WaitForValueChangedRequest |
with(DataReceivedCallback callback)
Sets the value callback.
|
awaitawait, await, awaitawait, await, enqueue, enqueuecreateBond, 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 WaitForValueChangedRequest setHandler(@NonNull android.os.Handler handler)
RequestBleManager will be used.setHandler in class TimeoutableRequesthandler - The handler to invoke callbacks for this request.@NonNull public WaitForValueChangedRequest timeout(long timeout)
TimeoutableRequestFailCallback.REASON_TIMEOUT.timeout in class TimeoutableValueRequest<DataReceivedCallback>timeout - the request timeout in milliseconds, 0 to disable timeout.@NonNull public WaitForValueChangedRequest done(@NonNull SuccessCallback callback)
Request@NonNull public WaitForValueChangedRequest fail(@NonNull FailCallback callback)
RequestBleManager.connect(BluetoothDevice) was never called), the
Request.invalid(InvalidRequestCallback) will be used instead, as the
BluetoothDevice is not known.
This callback will be ignored if request was executed synchronously, in which case the error will be returned as an exception.
@NonNull public WaitForValueChangedRequest invalid(@NonNull InvalidRequestCallback callback)
Request@NonNull public WaitForValueChangedRequest before(@NonNull BeforeCallback callback)
Request@NonNull public WaitForValueChangedRequest with(@NonNull DataReceivedCallback callback)
TimeoutableValueRequestawait(...) method;with in class TimeoutableValueRequest<DataReceivedCallback>callback - the callback.@NonNull public WaitForValueChangedRequest trigger(@NonNull Operation trigger)
AwaitingRequesttrigger in class AwaitingRequest<DataReceivedCallback>trigger - the operation that triggers the notification, usually a write characteristic
request that write some OP CODE.@NonNull public WaitForValueChangedRequest filter(@NonNull DataFilter filter)
filter - the data filter.@NonNull public WaitForValueChangedRequest merge(@NonNull DataMerger merger)
@NonNull public WaitForValueChangedRequest merge(@NonNull DataMerger merger, @NonNull ReadProgressCallback callback)
@NonNull public <E extends ProfileReadResponse> E awaitValid(@NonNull E response) throws RequestFailedException, InvalidDataException, DeviceDisconnectedException, BluetoothDisabledException, InvalidRequestException, java.lang.InterruptedException
TimeoutableValueRequest.await(Class), but if the response class extends
ProfileReadResponse and the received response is invalid, an exception is thrown.
This allows to keep all error handling in one place.E - a response class that extends ProfileReadResponse.response - the result object.java.lang.IllegalStateException - thrown when you try to call this method from
the main (UI) thread.java.lang.InterruptedException - thrown when the timeout occurred before the
characteristic value has changed.RequestFailedException - thrown when the trigger request has failed.DeviceDisconnectedException - thrown when the device disconnected before the
notification or indication was received.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).InvalidDataException - thrown when the received data were not valid (that is when
ReadResponse.onDataReceived(BluetoothDevice, Data)
failed to parse the data correctly and called
ProfileReadResponse.onInvalidDataReceived(BluetoothDevice, Data)).@NonNull public <E extends ProfileReadResponse> E awaitValid(@NonNull java.lang.Class<E> responseClass) throws RequestFailedException, InvalidDataException, DeviceDisconnectedException, BluetoothDisabledException, InvalidRequestException, java.lang.InterruptedException
#await(DataReceivedCallback), but if the response class extends
ProfileReadResponse and the received response is invalid, an exception is thrown.
This allows to keep all error handling in one place.E - a response class that extends ProfileReadResponse.responseClass - the result class. This class will be instantiate, therefore it
has to have a default constructor.java.lang.IllegalStateException - thrown when you try to call this method from
the main (UI) thread.java.lang.InterruptedException - thrown when the timeout occurred before the
characteristic value has changed.java.lang.IllegalArgumentException - thrown when the response class could not be instantiated.RequestFailedException - thrown when the trigger request has failed.DeviceDisconnectedException - thrown when the device disconnected before the
notification or indication was received.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).InvalidDataException - thrown when the received data were not valid (that is when
ReadResponse.onDataReceived(BluetoothDevice, Data)
failed to parse the data correctly and called
ProfileReadResponse.onInvalidDataReceived(BluetoothDevice, Data)).@NonNull @Deprecated public <E extends ProfileReadResponse> E awaitValid(@NonNull java.lang.Class<E> responseClass, long timeout) throws java.lang.InterruptedException, InvalidDataException, RequestFailedException, DeviceDisconnectedException, BluetoothDisabledException, InvalidRequestException
timeout(long) and awaitValid(Class) instead.TimeoutableValueRequest.await(Class, long), but if received response is not valid, this method will
thrown an exception.E - a response class that extends ProfileReadResponse.responseClass - the result class. This class will be instantiate, therefore it
has to have a default constructor.timeout - optional timeout in milliseconds.java.lang.IllegalStateException - thrown when you try to call this method from
the main (UI) thread.java.lang.InterruptedException - thrown when the timeout occurred before the
characteristic value has changed.java.lang.IllegalArgumentException - thrown when the response class could not be instantiated.RequestFailedException - thrown when the trigger request has failed.DeviceDisconnectedException - thrown when the device disconnected before the
notification or indication was received.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).InvalidDataException - thrown when the received data were not valid (that is when
ReadResponse.onDataReceived(BluetoothDevice, Data)
failed to parse the data correctly and called
ProfileReadResponse.onInvalidDataReceived(BluetoothDevice, Data)).@NonNull @Deprecated public <E extends ProfileReadResponse> E awaitValid(@NonNull E response, long timeout) throws java.lang.InterruptedException, InvalidDataException, DeviceDisconnectedException, RequestFailedException, BluetoothDisabledException, InvalidRequestException
timeout(long) and #awaitValid(E) instead.TimeoutableValueRequest.await(Object, long), but if received response is not valid,
this method will thrown an exception.E - a response class that extends ProfileReadResponse.response - the result object.timeout - optional timeout in milliseconds.java.lang.IllegalStateException - thrown when you try to call this method from
the main (UI) thread.java.lang.InterruptedException - thrown when the timeout occurred before the
characteristic value has changed.RequestFailedException - thrown when the trigger request has failed.DeviceDisconnectedException - thrown when the device disconnected before the
notification or indication was received.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).InvalidDataException - thrown when the received data were not valid (that is when
ReadResponse.onDataReceived(BluetoothDevice, Data)
failed to parse the data correctly and called
ProfileReadResponse.onInvalidDataReceived(BluetoothDevice, Data)).