Class AdvertiseData

java.lang.Object
com.codename1.bluetooth.le.server.AdvertiseData

public class AdvertiseData extends Object

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

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