AdvertiseParams


public final class AdvertiseParams


A class to provide a way to adjust advertising preferences and advertise data packet.

Summary

Public constructors

AdvertiseParams(
    boolean shouldIncludeDeviceAddress,
    boolean shouldIncludeDeviceName,
    boolean isConnectable,
    boolean isDiscoverable,
    @IntRange(from = 0, to = 180000) long durationMillis,
    @NonNull Map<@NonNull Integer, @NonNull byte[]> manufacturerData,
    @NonNull Map<@NonNull UUID, @NonNull byte[]> serviceData,
    @NonNull List<@NonNull UUID> serviceUuids,
    @NonNull List<@NonNull UUID> serviceSolicitationUuids
)

Public methods

final long

Advertising duration in milliseconds.

final @NonNull Map<@NonNull Integer, @NonNull byte[]>

A map of company identifiers to manufacturer specific data.

final @NonNull Map<@NonNull UUID, @NonNull byte[]>

A map of 16-bit UUIDs of the services to corresponding additional service data.

final @NonNull List<@NonNull UUID>

A list of service solicitation UUIDs to advertise that we invite to connect.

final @NonNull List<@NonNull UUID>

A list of service UUIDs to advertise.

final boolean

Whether the advertisement will indicate connectable.

final boolean

Whether the advertisement will be discoverable.

final boolean

Whether the device address will be included in the advertisement packet.

final boolean

Whether the device name will be included in the advertisement packet.

Public constructors

AdvertiseParams

Added in 1.0.0-alpha02
public AdvertiseParams(
    boolean shouldIncludeDeviceAddress,
    boolean shouldIncludeDeviceName,
    boolean isConnectable,
    boolean isDiscoverable,
    @IntRange(from = 0, to = 180000) long durationMillis,
    @NonNull Map<@NonNull Integer, @NonNull byte[]> manufacturerData,
    @NonNull Map<@NonNull UUID, @NonNull byte[]> serviceData,
    @NonNull List<@NonNull UUID> serviceUuids,
    @NonNull List<@NonNull UUID> serviceSolicitationUuids
)

Public methods

getDurationMillis

Added in 1.0.0-alpha02
public final long getDurationMillis()

Advertising duration in milliseconds.

It must not exceed 180000 milliseconds. A value of 0 means advertising continues until it is stopped explicitly.

Throws
kotlin.IllegalArgumentException

if it is not in the range 0..180000.

getManufacturerData

Added in 1.0.0-alpha02
public final @NonNull Map<@NonNull Integer, @NonNull byte[]> getManufacturerData()

A map of company identifiers to manufacturer specific data.

Please refer to the Bluetooth Assigned Numbers document provided by the Bluetooth SIG for the list of existing company identifiers.

getServiceData

Added in 1.0.0-alpha02
public final @NonNull Map<@NonNull UUID, @NonNull byte[]> getServiceData()

A map of 16-bit UUIDs of the services to corresponding additional service data.

getServiceSolicitationUuids

Added in 1.0.0-alpha02
public final @NonNull List<@NonNull UUIDgetServiceSolicitationUuids()

A list of service solicitation UUIDs to advertise that we invite to connect.

getServiceUuids

Added in 1.0.0-alpha02
public final @NonNull List<@NonNull UUIDgetServiceUuids()

A list of service UUIDs to advertise.

isConnectable

Added in 1.0.0-alpha02
public final boolean isConnectable()

Whether the advertisement will indicate connectable.

isDiscoverable

Added in 1.0.0-alpha02
public final boolean isDiscoverable()

Whether the advertisement will be discoverable.

Please note that it would be ignored under API level 34 and isConnectable would be used instead.

shouldIncludeDeviceAddress

public final boolean shouldIncludeDeviceAddress()

Whether the device address will be included in the advertisement packet.

shouldIncludeDeviceName

public final boolean shouldIncludeDeviceName()

Whether the device name will be included in the advertisement packet.