# UwbClientSessionScope

Artifact: [androidx.core.uwb:uwb](https://developer.android.com/jetpack/androidx/releases/core-uwb) [View Source](https://cs.android.com/search?q=file:androidx/core/uwb/UwbClientSessionScope.kt+class:androidx.core.uwb.UwbClientSessionScope) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core-uwb#1.0.0)

*** ** * ** ***


```
interface UwbClientSessionScope
```

<br />

Known direct subclasses [UwbControleeSessionScope](https://developer.android.com/reference/kotlin/androidx/core/uwb/UwbControleeSessionScope), [UwbControllerSessionScope](https://developer.android.com/reference/kotlin/androidx/core/uwb/UwbControllerSessionScope)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/uwb/UwbControleeSessionScope` | Interface for controlee client session that is established between nearby UWB devices. |
| `https://developer.android.com/reference/kotlin/androidx/core/uwb/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 |
|---|---|
| `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://developer.android.com/reference/kotlin/androidx/core/uwb/RangingResult>` | `https://developer.android.com/reference/kotlin/androidx/core/uwb/UwbClientSessionScope#prepareSession(androidx.core.uwb.RangingParameters)(parameters: https://developer.android.com/reference/kotlin/androidx/core/uwb/RangingParameters)` Returns a flow of `https://developer.android.com/reference/kotlin/androidx/core/uwb/RangingResult`. |
| `open https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://developer.android.com/reference/kotlin/androidx/core/uwb/SensorFusionResult>` | `https://developer.android.com/reference/kotlin/androidx/core/uwb/UwbClientSessionScope#prepareSession(androidx.core.uwb.SensorFusionParameters)(parameters: https://developer.android.com/reference/kotlin/androidx/core/uwb/SensorFusionParameters)` Prepare a sensor fusion session, which performs software angle of arrival estimation and adjusts range for local device motion at a high resolution. |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/uwb/UwbClientSessionScope#reconfigureRangeDataNtf(kotlin.Int,kotlin.Int,kotlin.Int)( configType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, proximityNear: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, proximityFar: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Dynamically reconfigures range data notification config to an active ranging session. |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/uwb/UwbAddress` | `https://developer.android.com/reference/kotlin/androidx/core/uwb/UwbClientSessionScope#localAddress()` A local address can only be used for a single ranging session. |
| `https://developer.android.com/reference/kotlin/androidx/core/uwb/RangingCapabilities` | `https://developer.android.com/reference/kotlin/androidx/core/uwb/UwbClientSessionScope#rangingCapabilities()` Returns the `https://developer.android.com/reference/kotlin/androidx/core/uwb/RangingCapabilities` which the device supports. |

| ### Extension functions |
|---|---|
| `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html<https://developer.android.com/reference/kotlin/androidx/core/uwb/RangingResult>` | `https://developer.android.com/reference/kotlin/androidx/core/uwb/UwbClientSessionScope.https://developer.android.com/reference/kotlin/androidx/core/uwb/UwbClientSessionScope#(androidx.core.uwb.UwbClientSessionScope).rangingResultsFlowable(androidx.core.uwb.RangingParameters)( parameters: https://developer.android.com/reference/kotlin/androidx/core/uwb/RangingParameters )` Returns a `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html` of `https://developer.android.com/reference/kotlin/androidx/core/uwb/RangingResult`. |
| `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html<https://developer.android.com/reference/kotlin/androidx/core/uwb/RangingResult>` | `https://developer.android.com/reference/kotlin/androidx/core/uwb/UwbClientSessionScope.https://developer.android.com/reference/kotlin/androidx/core/uwb/UwbClientSessionScope#(androidx.core.uwb.UwbClientSessionScope).rangingResultsObservable(androidx.core.uwb.RangingParameters)( parameters: https://developer.android.com/reference/kotlin/androidx/core/uwb/RangingParameters )` Returns an `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html` stream of `https://developer.android.com/reference/kotlin/androidx/core/uwb/RangingResult`. |

## Public functions

### prepareSession

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core-uwb#1.0.0)

```
fun prepareSession(parameters: RangingParameters): Flow<RangingResult>
```

Returns a flow of `https://developer.android.com/reference/kotlin/androidx/core/uwb/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 |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if a new flow was consumed again after the UWB ranging is already initiated. |
| `https://developer.android.com/reference/kotlin/androidx/core/uwb/exceptions/UwbSystemCallbackException` | if the backend UWB system has resulted in an error. |
| `https://developer.android.com/reference/java/lang/SecurityException.html` | if ranging does not have the `android.permission.UWB_RANGING` permission. Apps must have requested and been granted this permission before calling this method. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the client starts a ranging session without setting complex channel and peer address. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the client starts a ranging session with invalid config id or ranging update type. |

### prepareSession

Added in [1.1.0-alpha03](https://developer.android.com/jetpack/androidx/releases/core-uwb#1.1.0-alpha03)

```
open fun prepareSession(parameters: SensorFusionParameters): Flow<SensorFusionResult>
```

Prepare a sensor fusion session, which performs software angle of arrival 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](https://developers.google.com/ar/develop/java/enable-arcore).

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 `https://developer.android.com/reference/kotlin/androidx/core/uwb/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 `https://developer.android.com/reference/kotlin/androidx/core/uwb/SensorFusionResult.SensorFusionFallback` and the session will fall back to standard UWB ranging. That is, all subsequent results will be instances of `https://developer.android.com/reference/kotlin/androidx/core/uwb/RangingResult`.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if a new flow was consumed again after the UWB ranging is already initiated. |
| `https://developer.android.com/reference/kotlin/androidx/core/uwb/exceptions/UwbSystemCallbackException` | if the backend UWB system has resulted in an error. |
| `https://developer.android.com/reference/java/lang/SecurityException.html` | if the app does not have both the `android.permission.UWB_RANGING` and `https://developer.android.com/reference/android/Manifest.permission.html#CAMERA` permissions. Apps must have requested and been granted these permissions before calling this method. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the client starts a ranging session without setting complex channel and peer address. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the client starts a ranging session with invalid config id or ranging update type. |

### reconfigureRangeDataNtf

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core-uwb#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 |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the ranging is inactive. Otherwise, this method will return successfully, then clients are expected to handle `https://developer.android.com/reference/kotlin/androidx/core/uwb/RangingResult.RangingResultFailure` with the controlee as parameter of the callback. |

## Public properties

### localAddress

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core-uwb#1.0.0)

```
val localAddress: UwbAddress
```

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](https://developer.android.com/jetpack/androidx/releases/core-uwb#1.0.0)

```
val rangingCapabilities: RangingCapabilities
```

Returns the `https://developer.android.com/reference/kotlin/androidx/core/uwb/RangingCapabilities` which the device supports.

## Extension functions

### UwbClientSessionScope.rangingResultsFlowable

Artifact: [androidx.core.uwb:uwb-rxjava3](https://developer.android.com/jetpack/androidx/releases/core-uwb) [View Source](https://cs.android.com/search?q=file:androidx/core/uwb/rxjava3/UwbClientSessionScopeRx.kt+function:rangingResultsFlowable)

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

Returns a `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Flowable.html` of `https://developer.android.com/reference/kotlin/androidx/core/uwb/RangingResult`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/uwb/UwbClientSessionScope#prepareSession(androidx.core.uwb.RangingParameters)` |   |

### UwbClientSessionScope.rangingResultsObservable

Artifact: [androidx.core.uwb:uwb-rxjava3](https://developer.android.com/jetpack/androidx/releases/core-uwb) [View Source](https://cs.android.com/search?q=file:androidx/core/uwb/rxjava3/UwbClientSessionScopeRx.kt+function:rangingResultsObservable)

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

Returns an `http://reactivex.io/RxJava/3.x/javadoc/io/reactivex/rxjava3/core/Observable.html` stream of `https://developer.android.com/reference/kotlin/androidx/core/uwb/RangingResult`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/uwb/UwbClientSessionScope#prepareSession(androidx.core.uwb.RangingParameters)` |   |