UwbClientSessionScope

public interface UwbClientSessionScope

Known direct subclasses
UwbControleeSessionScope

Interface for controlee client session that is established between nearby UWB devices.

UwbControllerSessionScope

Interface for controller client session that is established between nearby UWB devices.


Interface for client session that is established between nearby UWB devices.

Summary

Public methods

abstract @NonNull UwbAddress

A local address can only be used for a single ranging session.

abstract @NonNull RangingCapabilities

Returns the RangingCapabilities which the device supports.

abstract @NonNull Flow<@NonNull RangingResult>

Returns a flow of RangingResult.

abstract void
reconfigureRangeDataNtf(
    int configType,
    int proximityNear,
    int proximityFar
)

Dynamically reconfigures range data notification config to an active ranging session.

Public methods

getLocalAddress

Added in 1.0.0-alpha08
abstract @NonNull UwbAddress getLocalAddress()

A local address can only be used for a single ranging session. After a ranging session is ended, a new address will be allocated.

Ranging session duration may also be limited to prevent addresses from being used for too long. In this case, your ranging session would be suspended and clients would need to exchange the new address with their peer before starting again.

getRangingCapabilities

Added in 1.0.0-alpha08
abstract @NonNull RangingCapabilities getRangingCapabilities()

Returns the RangingCapabilities which the device supports.

prepareSession

Added in 1.0.0-alpha08
abstract @NonNull Flow<@NonNull RangingResultprepareSession(@NonNull RangingParameters parameters)

Returns a flow of RangingResult. Consuming the flow will initiate the UWB ranging and only one flow can be initiated. To consume the flow from multiple consumers, convert the flow to a SharedFlow.

Throws
kotlin.IllegalStateException

if a new flow was consumed again after the UWB ranging is already initiated.

androidx.core.uwb.exceptions.UwbSystemCallbackException

if the backend UWB system has resulted in an error.

java.lang.SecurityException

if ranging does not have the android.permission.UWB_RANGING permission. Apps must have requested and been granted this permission before calling this method.

kotlin.IllegalArgumentException

if the client starts a ranging session without setting complex channel and peer address.

kotlin.IllegalArgumentException

if the client starts a ranging session with invalid config id or ranging update type.

reconfigureRangeDataNtf

Added in 1.0.0-alpha08
abstract void reconfigureRangeDataNtf(
    int configType,
    int proximityNear,
    int proximityFar
)

Dynamically reconfigures range data notification config to an active ranging session.

Throws
kotlin.IllegalStateException

if the ranging is inactive.

Otherwise, this method will return successfully, then clients are expected to handle RangingResult.RangingResultPeerDisconnected with the controlee as parameter of the callback.

Extension functions

UwbClientSessionScopeRx.rangingResultsFlowable

default final @NonNull Flowable<@NonNull RangingResultUwbClientSessionScopeRx.rangingResultsFlowable(
    @NonNull UwbClientSessionScope receiver,
    @NonNull RangingParameters parameters
)

Returns a Flowable of RangingResult.

See also
prepareSession

UwbClientSessionScopeRx.rangingResultsObservable

default final @NonNull Observable<@NonNull RangingResultUwbClientSessionScopeRx.rangingResultsObservable(
    @NonNull UwbClientSessionScope receiver,
    @NonNull RangingParameters parameters
)

Returns an Observable stream of RangingResult.

See also
prepareSession