advertise

open suspend override fun advertise(connectable: Boolean, payload: AdvertisingPayload, timeout: Duration, block: (txPower: Int) -> Unit?)


suspend fun advertise(parameters: AdvertisingSetParameters, payload: AdvertisingPayload, timeout: Duration, block: (txPower: Int) -> Unit?)

Starts Bluetooth LE advertising using given parameters.

Parameters

parameters

Advertising parameters describing how the data are to be advertised.

payload

Advertising data to be broadcast.

timeout

The advertising time limit. May not exceed 180.000 ms on Android 5-7 and 655.350 ms on Android 8+. By default there is no timeout set.

block

A block that will be called when the advertising is started. The block will receive the actual TX power (in dBm) used for advertising.

Throws

If the BLUETOOTH_ADVERTISE permission is denied.

If the advertising could not be started.

If the advertising data is invalid.


suspend fun advertise(parameters: AdvertisingSetParameters, payload: AdvertisingPayload, maxAdvertisingEvents: @Range(from = 1, to = 255) Int, block: (txPower: Int) -> Unit?)

Starts Bluetooth LE advertising using given parameters.

Parameters

parameters

Advertising parameters describing how the data are to be advertised.

payload

Advertising data to be broadcast.

maxAdvertisingEvents

The maximum number of advertising events, in range 1-255.

block

A block that will be called when the advertising is started. The block will receive the actual TX power (in dBm) used for advertising.

Throws

If the BLUETOOTH_ADVERTISE permission is denied.

If the advertising could not be started.

If the advertising data is invalid.