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