Class AdvertisementData
java.lang.Object
com.codename1.bluetooth.le.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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddManufacturerData(int companyId, byte[] data) Populated by ports; not application API.voidaddServiceData(BluetoothUuid uuid, byte[] data) Populated by ports; not application API.voidaddServiceUuid(BluetoothUuid uuid) Populated by ports; not application API.The advertised local name, ornullwhen the advertisement carries none.byte[]getManufacturerData(int companyId) The manufacturer-specific payload advertised for the given company identifier, ornull.int[]The company identifiers for which manufacturer data is present.byte[]The raw advertisement bytes when the platform exposes them (Android, simulator);nullon iOS, which only provides parsed fields.byte[]getServiceData(BluetoothUuid serviceUuid) The service-data payload advertised for the given service UUID, ornull.The service UUIDs for which service data is present.The advertised service UUIDs; empty when none were advertised.The advertised TX power level in dBm, ornullwhen absent.static AdvertisementDataparse(byte[] raw) Parses raw advertisement bytes -- a sequence oflength, type, payloadAD structures -- into a populated instance.voidsetLocalName(String localName) Populated by ports; not application API.voidsetTxPowerLevel(Integer txPowerLevel) Populated by ports; not application API.
-
Constructor Details
-
AdvertisementData
public AdvertisementData()
-
-
Method Details
-
parse
Parses raw advertisement bytes -- a sequence oflength, type, payloadAD structures -- into a populated instance. Unknown AD types are skipped; a malformed trailing structure ends parsing without failing. -
getLocalName
The advertised local name, ornullwhen the advertisement carries none. -
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, ornull. -
getManufacturerIds
public int[] getManufacturerIds()The company identifiers for which manufacturer data is present. -
getServiceData
The service-data payload advertised for the given service UUID, ornull. -
getServiceDataUuids
The service UUIDs for which service data is present. -
getTxPowerLevel
The advertised TX power level in dBm, ornullwhen absent. -
getRawBytes
public byte[] getRawBytes()The raw advertisement bytes when the platform exposes them (Android, simulator);nullon iOS, which only provides parsed fields. -
setLocalName
Populated by ports; not application API. -
addServiceUuid
Populated by ports; not application API. -
addManufacturerData
public void addManufacturerData(int companyId, byte[] data) Populated by ports; not application API. -
addServiceData
Populated by ports; not application API. -
setTxPowerLevel
Populated by ports; not application API.
-