public class AdvertisementData

  1. Object
  2. AdvertisementData

The parsed payload of a BLE advertisement: local name, advertised service UUIDs, manufacturer data, service data and TX power. Obtained from ScanResult.getAdvertisementData().

Ports that receive raw advertisement bytes (Android, the simulator) build instances via [#parse(byte[])]; ports that only get pre-parsed dictionaries (iOS) populate the fields directly through the set* / add* methods, which are not application API.

Constructors

public AdvertisementData()

Methods

public static AdvertisementData parse(byte[] raw)Parses raw advertisement bytes – a sequence of length, type, payload AD structures – into a populated instance.
public String getLocalName()The advertised local name, or null when the advertisement carries none.
public List<BluetoothUuid> getServiceUuids()The advertised service UUIDs; empty when none were advertised.
public byte[] getManufacturerData(int companyId)The manufacturer-specific payload advertised for the given company identifier, or null.
public int[] getManufacturerIds()The company identifiers for which manufacturer data is present.
public byte[] getServiceData(BluetoothUuid serviceUuid)The service-data payload advertised for the given service UUID, or null.
public List<BluetoothUuid> getServiceDataUuids()The service UUIDs for which service data is present.
public Integer getTxPowerLevel()The advertised TX power level in dBm, or null when absent.
public byte[] getRawBytes()The raw advertisement bytes when the platform exposes them (Android, simulator); null on iOS, which only provides parsed fields.
public void setLocalName(String localName)Populated by ports; not application API.
public void addServiceUuid(BluetoothUuid uuid)Populated by ports; not application API.
public void addManufacturerData(int companyId, byte[] data)Populated by ports; not application API.
public void addServiceData(BluetoothUuid uuid, byte[] data)Populated by ports; not application API.
public void setTxPowerLevel(Integer txPowerLevel)Populated by ports; not application API.

Inherited methods

Constructor details

AdvertisementData

public AdvertisementData()

Method details

parse

public static AdvertisementData parse(byte[] raw)
Parses raw advertisement bytes – a sequence of length, type, payload AD structures – into a populated instance. Unknown AD types are skipped; a malformed trailing structure ends parsing without failing.

getLocalName

public String getLocalName()
The advertised local name, or null when the advertisement carries none.

getServiceUuids

public List<BluetoothUuid> getServiceUuids()
The advertised service UUIDs; empty when none were advertised.

getManufacturerData

public byte[] getManufacturerData(int companyId)
The manufacturer-specific payload advertised for the given company identifier, or null.

getManufacturerIds

public int[] getManufacturerIds()
The company identifiers for which manufacturer data is present.

getServiceData

public byte[] getServiceData(BluetoothUuid serviceUuid)
The service-data payload advertised for the given service UUID, or null.

getServiceDataUuids

public List<BluetoothUuid> getServiceDataUuids()
The service UUIDs for which service data is present.

getTxPowerLevel

public Integer getTxPowerLevel()
The advertised TX power level in dBm, or null when absent.

getRawBytes

public byte[] getRawBytes()
The raw advertisement bytes when the platform exposes them (Android, simulator); null on iOS, which only provides parsed fields.

setLocalName

public void setLocalName(String localName)
Populated by ports; not application API.

addServiceUuid

public void addServiceUuid(BluetoothUuid uuid)
Populated by ports; not application API.

addManufacturerData

public void addManufacturerData(int companyId, byte[] data)
Populated by ports; not application API.

addServiceData

public void addServiceData(BluetoothUuid uuid, byte[] data)
Populated by ports; not application API.

setTxPowerLevel

public void setTxPowerLevel(Integer txPowerLevel)
Populated by ports; not application API.