Builder
class Builder
kotlin.Any | |
↳ | android.bluetooth.le.AdvertisingSetParameters.Builder |
Builder class for AdvertisingSetParameters
.
Summary
Public constructors | |
---|---|
Builder() |
Public methods | |
---|---|
AdvertisingSetParameters! |
build() Build the |
AdvertisingSetParameters.Builder! |
setAnonymous(isAnonymous: Boolean) Set whether advertiser address should be omitted from all packets. |
AdvertisingSetParameters.Builder! |
setConnectable(connectable: Boolean) Set whether the advertisement type should be connectable or non-connectable. |
AdvertisingSetParameters.Builder |
setDiscoverable(discoverable: Boolean) Set whether the advertisement type should be discoverable or non-discoverable. |
AdvertisingSetParameters.Builder! |
setIncludeTxPower(includeTxPower: Boolean) Set whether TX power should be included in the extended header. |
AdvertisingSetParameters.Builder! |
setInterval(interval: Int) Set advertising interval. |
AdvertisingSetParameters.Builder! |
setLegacyMode(isLegacy: Boolean) When set to true, advertising set will advertise 4. |
AdvertisingSetParameters.Builder! |
setPrimaryPhy(primaryPhy: Int) Set the primary physical channel used for this advertising set. |
AdvertisingSetParameters.Builder! |
setScannable(scannable: Boolean) Set whether the advertisement type should be scannable. |
AdvertisingSetParameters.Builder! |
setSecondaryPhy(secondaryPhy: Int) Set the secondary physical channel used for this advertising set. |
AdvertisingSetParameters.Builder! |
setTxPowerLevel(txPowerLevel: Int) Set the transmission power level for the advertising. |
Public constructors
Public methods
build
fun build(): AdvertisingSetParameters!
Build the AdvertisingSetParameters
object.
Exceptions | |
---|---|
java.lang.IllegalStateException |
if invalid combination of parameters is used. |
setAnonymous
fun setAnonymous(isAnonymous: Boolean): AdvertisingSetParameters.Builder!
Set whether advertiser address should be omitted from all packets. If this mode is used, periodic advertising can't be enabled for this set.
This is used only if legacy mode is not used.
Parameters | |
---|---|
isAnonymous |
Boolean: whether anonymous advertising should be used. |
setConnectable
fun setConnectable(connectable: Boolean): AdvertisingSetParameters.Builder!
Set whether the advertisement type should be connectable or non-connectable. Legacy advertisements can be both connectable and scannable. Non-legacy advertisements can be only scannable or only connectable.
Parameters | |
---|---|
connectable |
Boolean: Controls whether the advertisement type will be connectable (true) or non-connectable (false). |
setDiscoverable
fun setDiscoverable(discoverable: Boolean): AdvertisingSetParameters.Builder
Set whether the advertisement type should be discoverable or non-discoverable. By default, advertisements will be discoverable. Devices connecting to non-discoverable advertisements cannot initiate bonding.
Parameters | |
---|---|
discoverable |
Boolean: Controls whether the advertisement type will be discoverable (true ) or non-discoverable (false ). |
Return | |
---|---|
AdvertisingSetParameters.Builder |
This value cannot be null . |
setIncludeTxPower
fun setIncludeTxPower(includeTxPower: Boolean): AdvertisingSetParameters.Builder!
Set whether TX power should be included in the extended header.
This is used only if legacy mode is not used.
Parameters | |
---|---|
includeTxPower |
Boolean: whether TX power should be included in extended header |
setInterval
fun setInterval(interval: Int): AdvertisingSetParameters.Builder!
Set advertising interval.
Parameters | |
---|---|
interval |
Int: Bluetooth LE Advertising interval, in 0.625ms unit. Valid range is from 160 (100ms) to 16777215 (10,485.759375 s). Recommended values are: android.bluetooth.le.AdvertisingSetParameters#INTERVAL_LOW , android.bluetooth.le.AdvertisingSetParameters#INTERVAL_MEDIUM , or android.bluetooth.le.AdvertisingSetParameters#INTERVAL_HIGH . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the interval is invalid. |
setLegacyMode
fun setLegacyMode(isLegacy: Boolean): AdvertisingSetParameters.Builder!
When set to true, advertising set will advertise 4.x Spec compliant advertisements.
Parameters | |
---|---|
isLegacy |
Boolean: whether legacy advertising mode should be used. |
setPrimaryPhy
fun setPrimaryPhy(primaryPhy: Int): AdvertisingSetParameters.Builder!
Set the primary physical channel used for this advertising set.
This is used only if legacy mode is not used.
Use BluetoothAdapter.isLeCodedPhySupported
to determine if LE Coded PHY is supported on this device.
Parameters | |
---|---|
primaryPhy |
Int: Primary advertising physical channel, can only be android.bluetooth.BluetoothDevice#PHY_LE_1M or BluetoothDevice.PHY_LE_CODED . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the primaryPhy is invalid. |
setScannable
fun setScannable(scannable: Boolean): AdvertisingSetParameters.Builder!
Set whether the advertisement type should be scannable. Legacy advertisements can be both connectable and scannable. Non-legacy advertisements can be only scannable or only connectable.
Parameters | |
---|---|
scannable |
Boolean: Controls whether the advertisement type will be scannable (true) or non-scannable (false). |
setSecondaryPhy
fun setSecondaryPhy(secondaryPhy: Int): AdvertisingSetParameters.Builder!
Set the secondary physical channel used for this advertising set.
This is used only if legacy mode is not used.
Use BluetoothAdapter.isLeCodedPhySupported
and android.bluetooth.BluetoothAdapter#isLe2MPhySupported
to determine if LE Coded PHY or 2M PHY is supported on this device.
Parameters | |
---|---|
secondaryPhy |
Int: Secondary advertising physical channel, can only be one of android.bluetooth.BluetoothDevice#PHY_LE_1M , BluetoothDevice.PHY_LE_2M or android.bluetooth.BluetoothDevice#PHY_LE_CODED . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the secondaryPhy is invalid. |
setTxPowerLevel
fun setTxPowerLevel(txPowerLevel: Int): AdvertisingSetParameters.Builder!
Set the transmission power level for the advertising.
Parameters | |
---|---|
txPowerLevel |
Int: Transmission power of Bluetooth LE Advertising, in dBm. The valid range is [-127, 1] Recommended values are: android.bluetooth.le.AdvertisingSetParameters#TX_POWER_ULTRA_LOW , android.bluetooth.le.AdvertisingSetParameters#TX_POWER_LOW , android.bluetooth.le.AdvertisingSetParameters#TX_POWER_MEDIUM , or android.bluetooth.le.AdvertisingSetParameters#TX_POWER_HIGH . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
If the txPowerLevel is invalid. |