UwbClientSessionScope


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 functions

Flow<RangingResult>

Returns a flow of RangingResult.

open Flow<SensorFusionResult>

Prepare a sensor fusion session, which performs software AoA estimation and adjusts range for local device motion at a high resolution.

suspend Unit
reconfigureRangeDataNtf(
    configType: Int,
    proximityNear: Int,
    proximityFar: Int
)

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

Public properties

UwbAddress

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

RangingCapabilities

Returns the RangingCapabilities which the device supports.

Public functions

prepareSession

Added in 1.0.0
fun prepareSession(parameters: RangingParameters): Flow<RangingResult>

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
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.

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.

IllegalArgumentException

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

IllegalArgumentException

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

prepareSession

Added in 1.1.0-alpha02
open fun prepareSession(parameters: SensorFusionParameters): Flow<SensorFusionResult>

Prepare a sensor fusion session, which performs software AoA estimation and adjusts range for local device motion at a high resolution.

Sensor fusion relies on ARCore to estimate local device odometry. Before calling this method, you must follow ARCore documentation to enable AR in your app.

This method has 2 possible failure modes:

  • "Hard failures" that indicate lack of accountability from the caller. When one of these occurs, the returned flow will produce a RangingResult.RangingResultFailure and stop.

  • "Soft failures" that arise from conditions that the caller may not have direct control over. When one of these occurs, the returned flow will produce a SensorFusionResult.SensorFusionFallback and the session will fall back to standard UWB ranging. That is, all subsequent results will be instances of RangingResult.

Throws the same exceptions as prepareSession(RangingParameters), in addition to:

Throws
SecurityException

if the app does not have the android.Manifest.permission.CAMERA permission. Apps must have requested and been granted this permission before calling this method.

reconfigureRangeDataNtf

Added in 1.0.0
suspend fun reconfigureRangeDataNtf(
    configType: Int,
    proximityNear: Int,
    proximityFar: Int
): Unit

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

Throws
IllegalStateException

if the ranging is inactive.

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

Public properties

localAddress

Added in 1.0.0
val localAddressUwbAddress

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.

rangingCapabilities

Added in 1.0.0
val rangingCapabilitiesRangingCapabilities

Returns the RangingCapabilities which the device supports.

Extension functions

UwbClientSessionScope.rangingResultsFlowable

fun UwbClientSessionScope.rangingResultsFlowable(
    parameters: RangingParameters
): Flowable<RangingResult>

Returns a Flowable of RangingResult.

See also
prepareSession

UwbClientSessionScope.rangingResultsObservable

fun UwbClientSessionScope.rangingResultsObservable(
    parameters: RangingParameters
): Observable<RangingResult>

Returns an Observable stream of RangingResult.

See also
prepareSession