public class AdvertiseData

  1. Object
  2. AdvertiseData

The payload to advertise via BluetoothLE.startAdvertising. Keep it small – a legacy advertisement carries at most 31 bytes; oversized payloads fail with BluetoothError.ADVERTISE_FAILED. Fluent setters return this for chaining.

Platform note: iOS only broadcasts the local name and service UUIDs – CoreBluetooth silently ignores manufacturer data, service data and TX power inclusion when advertising (Android broadcasts everything).

Constructors

public AdvertiseData()

Methods

public AdvertiseData addServiceUuid(BluetoothUuid uuid)Advertises the given service UUID so filtered scans can find this peripheral.
public AdvertiseData setIncludeDeviceName(boolean include)Includes the device name in the advertisement (off by default – names use up scarce advertisement bytes).
public AdvertiseData setIncludeTxPower(boolean include)Includes the TX power level in the advertisement.
public AdvertiseData addManufacturerData(int companyId, byte[] data)Adds manufacturer-specific data for the given company identifier.
public AdvertiseData addServiceData(BluetoothUuid uuid, byte[] data)Adds service data for the given service UUID.
public List<BluetoothUuid> getServiceUuids()The service UUIDs to advertise.
public boolean isIncludeDeviceName()Whether the device name is included.
public boolean isIncludeTxPower()Whether the TX power level is included.
public Map<Integer, byte[]> getManufacturerData()The manufacturer data entries, keyed by company identifier.
public Map<BluetoothUuid, byte[]> getServiceData()The service data entries, keyed by service UUID.

Inherited methods

Constructor details

AdvertiseData

public AdvertiseData()

Method details

addServiceUuid

public AdvertiseData addServiceUuid(BluetoothUuid uuid)
Advertises the given service UUID so filtered scans can find this peripheral.

setIncludeDeviceName

public AdvertiseData setIncludeDeviceName(boolean include)
Includes the device name in the advertisement (off by default – names use up scarce advertisement bytes).

setIncludeTxPower

public AdvertiseData setIncludeTxPower(boolean include)
Includes the TX power level in the advertisement.

addManufacturerData

public AdvertiseData addManufacturerData(int companyId, byte[] data)
Adds manufacturer-specific data for the given company identifier.

addServiceData

public AdvertiseData addServiceData(BluetoothUuid uuid, byte[] data)
Adds service data for the given service UUID.

getServiceUuids

public List<BluetoothUuid> getServiceUuids()
The service UUIDs to advertise.

isIncludeDeviceName

public boolean isIncludeDeviceName()
Whether the device name is included.

isIncludeTxPower

public boolean isIncludeTxPower()
Whether the TX power level is included.

getManufacturerData

public Map<Integer, byte[]> getManufacturerData()
The manufacturer data entries, keyed by company identifier.

getServiceData

public Map<BluetoothUuid, byte[]> getServiceData()
The service data entries, keyed by service UUID.