-
- All Implemented Interfaces:
-
no.nordicsemi.android.ble.Operation
public final class WaitForValueChangedRequest extends AwaitingRequest<DataReceivedCallback> implements Operation
-
-
Method Summary
Modifier and Type Method Description WaitForValueChangedRequestsetHandler(@Nullable() Handler handler)Sets the handler that will be used to invoke callbacks. WaitForValueChangedRequesttimeout(@IntRange(from = 0) long timeout)Sets the operation timeout. WaitForValueChangedRequestdone(@NonNull() SuccessCallback callback)Use to set a completion callback. WaitForValueChangedRequestfail(@NonNull() FailCallback callback)Use to set a callback that will be called in case the request has failed. WaitForValueChangedRequestinvalid(@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. WaitForValueChangedRequestbefore(@NonNull() BeforeCallback callback)Sets a callback that will be executed before the execution of this operation starts. WaitForValueChangedRequestthen(@NonNull() AfterCallback callback)Sets a callback that will be executed when the request has been processed, no matterthe request result. WaitForValueChangedRequestwith(@NonNull() DataReceivedCallback callback)Sets the value callback. WaitForValueChangedRequesttrigger(@NonNull() Operation trigger)Sets an optional request that is suppose to trigger the notification or indication.This is to ensure that the characteristic value won't change before the callback was set. WaitForValueChangedRequestfilter(@NonNull() DataFilter filter)Sets a filter which allows to skip some incoming data. WaitForValueChangedRequestfilterPacket(@NonNull() PacketFilter filter)Sets a packet filter which allows to ignore the complete packet. WaitForValueChangedRequestmerge(@NonNull() DataMerger merger)Adds a merger that will be used to merge multiple packets into a single Data.The merger may modify each packet if necessary. WaitForValueChangedRequestmerge(@NonNull() DataMerger merger, @NonNull() ReadProgressCallback callback)Adds a merger that will be used to merge multiple packets into a single Data.The merger may modify each packet if necessary. <E extends ProfileReadResponse> EawaitValid(@NonNull() E response)Similar to await, 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 extends ProfileReadResponse> EawaitValid(@NonNull() Class<E> responseClass)Similar to await, 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 extends ProfileReadResponse> EawaitValid(@NonNull() Class<E> responseClass, @IntRange(from = 0) long timeout)Same as await, but if received response is not valid, this method willthrown an exception. <E extends ProfileReadResponse> EawaitValid(@NonNull() E response, @IntRange(from = 0) long timeout)Same as await, but if received response is not valid,this method will thrown an exception. -
Methods inherited from class no.nordicsemi.android.ble.AwaitingRequest
await, trigger -
Methods inherited from class no.nordicsemi.android.ble.TimeoutableValueRequest
await, await, await, timeout, with -
Methods inherited from class no.nordicsemi.android.ble.TimeoutableRequest
await, await, cancel, 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() WaitForValueChangedRequest 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.
-
timeout
@NonNull() WaitForValueChangedRequest 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.
-
done
@NonNull() WaitForValueChangedRequest 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() WaitForValueChangedRequest 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() WaitForValueChangedRequest 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() WaitForValueChangedRequest before(@NonNull() BeforeCallback callback)
Sets a callback that will be executed before the execution of this operation starts.
- Parameters:
callback- the callback.
-
then
@NonNull() WaitForValueChangedRequest 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.
-
with
@NonNull() WaitForValueChangedRequest with(@NonNull() DataReceivedCallback callback)
Sets the value callback. When the request is invoked synchronously, this callback willbe ignored and the received value will be returned by the
await(...)method;- Parameters:
callback- the callback.
-
trigger
@NonNull() WaitForValueChangedRequest trigger(@NonNull() Operation trigger)
Sets an optional request that is suppose to trigger the notification or indication.This is to ensure that the characteristic value won't change before the callback was set.
- Parameters:
trigger- the operation that triggers the notification, usually a write characteristicrequest that write some OP CODE.
-
filter
@NonNull() WaitForValueChangedRequest filter(@NonNull() DataFilter filter)
Sets a filter which allows to skip some incoming data.
This filter filters each received packet before they are given to the data merger.To filter the complete packet after merging, use filterPacket instead.
- Parameters:
filter- the data filter.
-
filterPacket
@NonNull() WaitForValueChangedRequest filterPacket(@NonNull() PacketFilter filter)
Sets a packet filter which allows to ignore the complete packet.
This filter differs from the filter, as it checks the completepacket, after it has been merged. If there is not merger set, this does the same asthe data filter.
- Parameters:
filter- the packet filter.
-
merge
@NonNull() WaitForValueChangedRequest merge(@NonNull() DataMerger merger)
Adds a merger that will be used to merge multiple packets into a single Data.The merger may modify each packet if necessary.
-
merge
@NonNull() WaitForValueChangedRequest merge(@NonNull() DataMerger merger, @NonNull() ReadProgressCallback callback)
Adds a merger that will be used to merge multiple packets into a single Data.The merger may modify each packet if necessary.
-
awaitValid
@NonNull() <E extends ProfileReadResponse> E awaitValid(@NonNull() E response)
Similar to await, 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.
- Parameters:
response- the result object.
-
awaitValid
@NonNull() <E extends ProfileReadResponse> E awaitValid(@NonNull() Class<E> responseClass)
Similar to await, 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.
- Parameters:
responseClass- the result class.
-
awaitValid
@NonNull()@Deprecated() <E extends ProfileReadResponse> E awaitValid(@NonNull() Class<E> responseClass, @IntRange(from = 0) long timeout)
Same as await, but if received response is not valid, this method willthrown an exception.
- Parameters:
responseClass- the result class.timeout- optional timeout in milliseconds.
-
awaitValid
@NonNull()@Deprecated() <E extends ProfileReadResponse> E awaitValid(@NonNull() E response, @IntRange(from = 0) long timeout)
Same as await, but if received response is not valid,this method will thrown an exception.
- Parameters:
response- the result object.timeout- optional timeout in milliseconds.
-
-
-
-