Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

```
class Builder
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.ranging.wifi.pd.WifiPdRangingParams.Builder](https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#) |

Builder for `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams`.

This class provides a convenient way to construct `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams` objects. The MAC address of the peer device and the ranging service role are mandatory parameters and must be provided during the Builder's construction. Other parameters are optional and can be set using the respective setter methods.

Example usage:

```kotlin
<code>MacAddress peerMacAddress = MacAddress.fromString("01:02:03:04:05:06");
  WifiPdRangingParams params = new WifiPdRangingParams.Builder(peerMacAddress)
          .setDiscoveryChannelFrequencyMhz(5180)
          .setPasnMode(WifiPdRangingCapabilities.AUTHENTICATED_PASN_MODE)
          .setPassword("myPassword")
          .setDeviceIk(new byte[] {0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C})
          .build();
  </code>
```

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#Builder(android.net.MacAddress)(peerMacAddress: https://developer.android.com/reference/kotlin/android/net/MacAddress.html#)` Constructs a new `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#` for creating a ranging session. |

| Public methods ||
|---|---|
| [WifiPdRangingParams](https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams) | `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#build()()` Builds the `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams` object. |
| [WifiPdRangingParams.Builder](https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#setChannelWidth(kotlin.Int)(channelWidth: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the channel width. |
| [WifiPdRangingParams.Builder](https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#setDeviceIk(kotlin.ByteArray)(deviceIk: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html?)` Sets the device identity key (IK). |
| [WifiPdRangingParams.Builder](https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#setDiscoveryChannelFrequencyMhz(kotlin.Int)(discoveryChannelFrequencyMhz: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the discovery channel frequency in MHz. |
| [WifiPdRangingParams.Builder](https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#setPasnMode(kotlin.Int)(pasnMode: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the PASN (Pre-association security negotiation) mode. |
| [WifiPdRangingParams.Builder](https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#setPassword(kotlin.String)(password: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` Sets the password for the ranging session. |
| [WifiPdRangingParams.Builder](https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#setPreambleType(kotlin.Int)(preambleType: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the preamble type. |
| [WifiPdRangingParams.Builder](https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#setRangingUpdateRate(kotlin.Int)(rangingUpdateRate: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the ranging update rate. |
| [WifiPdRangingParams.Builder](https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#) | `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#setResponder80211azNtbSupported(kotlin.Boolean)(isResponder80211azNtbSupported: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Sets whether the responder supports 802. |

## Public constructors

### Builder

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
Builder(peerMacAddress: MacAddress)
```

Constructs a new `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#` for creating a ranging session.

| Parameters ||
|---|---|
| `peerMacAddress` | [MacAddress](https://developer.android.com/reference/kotlin/android/net/MacAddress.html#): The MAC address of the peer device. This value cannot be `null`. |

## Public methods

### build

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun build(): WifiPdRangingParams
```

Builds the `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams` object.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams` | The built `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams` object. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | if Device IK length is not 16 or password is empty. |
| `java.lang.NullPointerException` | if required parameters are not set. |

### setChannelWidth

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setChannelWidth(channelWidth: Int): WifiPdRangingParams.Builder
```

Sets the channel width.

| Parameters ||
|---|---|
| `channelWidth` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The channel width. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#CHANNEL_WIDTH_20MHZ:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#CHANNEL_WIDTH_40MHZ:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#CHANNEL_WIDTH_80MHZ:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#CHANNEL_WIDTH_160MHZ:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#CHANNEL_WIDTH_80MHZ_PLUS_MHZ:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#CHANNEL_WIDTH_320MHZ:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#` | The builder to facilitate chaining. This value cannot be `null`. |

### setDeviceIk

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setDeviceIk(deviceIk: ByteArray?): WifiPdRangingParams.Builder
```

Sets the device identity key (IK).

| Parameters ||
|---|---|
| `deviceIk` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)?: The device identity key. This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#` | The builder to facilitate chaining. This value cannot be `null`. |

### setDiscoveryChannelFrequencyMhz

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setDiscoveryChannelFrequencyMhz(discoveryChannelFrequencyMhz: Int): WifiPdRangingParams.Builder
```

Sets the discovery channel frequency in MHz.

| Parameters ||
|---|---|
| `discoveryChannelFrequencyMhz` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The discovery channel frequency in MHz. Value is between 2400 and 7125 inclusive |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#` | The builder to facilitate chaining. This value cannot be `null`. |

### setPasnMode

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setPasnMode(pasnMode: Int): WifiPdRangingParams.Builder
```

Sets the PASN (Pre-association security negotiation) mode.

| Parameters ||
|---|---|
| `pasnMode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The PASN mode. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingCapabilities#UNAUTHENTICATED_PASN_MODE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingCapabilities#AUTHENTICATED_PASN_MODE:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#` | The builder to facilitate chaining. This value cannot be `null`. |

### setPassword

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setPassword(password: String?): WifiPdRangingParams.Builder
```

Sets the password for the ranging session.

| Parameters ||
|---|---|
| `password` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?: The password for the ranging session. This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#` | The builder to facilitate chaining. This value cannot be `null`. |

### setPreambleType

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setPreambleType(preambleType: Int): WifiPdRangingParams.Builder
```

Sets the preamble type.

| Parameters ||
|---|---|
| `preambleType` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The preamble type. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#PREAMBLE_LEGACY:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#PREAMBLE_HT:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#PREAMBLE_VHT:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#PREAMBLE_HE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#PREAMBLE_EHT:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#` | The builder to facilitate chaining. This value cannot be `null`. |

### setRangingUpdateRate

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setRangingUpdateRate(rangingUpdateRate: Int): WifiPdRangingParams.Builder
```

Sets the ranging update rate.

| Parameters ||
|---|---|
| `rangingUpdateRate` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The ranging update rate. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#` | The builder to facilitate chaining. This value cannot be `null`. |

### setResponder80211azNtbSupported

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun setResponder80211azNtbSupported(isResponder80211azNtbSupported: Boolean): WifiPdRangingParams.Builder
```

Sets whether the responder supports 802.11az NTB.

| Parameters ||
|---|---|
| `isResponder80211azNtbSupported` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): Whether the responder supports 802.11az NTB. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/ranging/wifi/pd/WifiPdRangingParams.Builder#` | The builder to facilitate chaining. This value cannot be `null`. |