# Class AdvertisementData

java.lang.Object
com.codename1.bluetooth.le.AdvertisementData

public class AdvertisementData extends Object

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.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AdvertisementData()`

- ## Method Summary

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

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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.