public class ADPayloadParser extends Object
public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord)
{
List<ADStructure> structures = ADPayloadParser.getInstance().parse(scanRecord);
| Modifier and Type | Method and Description |
|---|---|
static ADPayloadParser |
getInstance()
Get the singleton instance.
|
List<ADStructure> |
parse(byte[] payload)
Parse a byte sequence as a list of AD structures.
|
List<ADStructure> |
parse(byte[] payload,
int offset,
int length)
Parse a byte sequence as a list of AD structures.
|
void |
registerBuilder(int type,
ADStructureBuilder builder)
Register an AD structure builder for the AD type.
|
void |
registerManufacturerSpecificBuilder(int companyId,
ADManufacturerSpecificBuilder builder)
Register a builder for the company ID.
|
public static ADPayloadParser getInstance()
public void registerBuilder(int type,
ADStructureBuilder builder)
Note that a builder for the type Manufacturer Specific Data
(0xFF) should not be registered by this method. Instead, use
registerManufacturerSpecificBuilder(int,
ADManufacturerSpecificBuilder).
type - AD type. The value must be in the range from 0 to 0xFF.builder - AD structure builder.public void registerManufacturerSpecificBuilder(int companyId,
ADManufacturerSpecificBuilder builder)
companyId - Company ID. The value must be in the range from 0 to 0xFFFF.builder - A builder.public List<ADStructure> parse(byte[] payload)
payload - A byte array containing of AD structures.payload
is null, this method returns null.public List<ADStructure> parse(byte[] payload, int offset, int length)
Supported AD structures are as follows.
Data Type Value Data Type Name Class 0x01Flags Flags0x02Incomplete List of 16-bit Service Class UUIDs UUIDs0x03Complete List of 16-bit Service Class UUIDs UUIDs0x04Incomplete List of 32-bit Service Class UUIDs UUIDs0x05Complete List of 32-bit Service Class UUIDs UUIDs0x06Incomplete List of 128-bit Service Class UUIDs UUIDs0x07Complete List of 128-bit Service Class UUIDs UUIDs0x14List of 16-bit Service Solicitation UUIDs UUIDs0x15List of 128-bit Service Solicitation UUIDs UUIDs0x16Service Data - 16-bit UUID ServiceData0x1FList of 32-bit Service Solicitation UUIDs UUIDs0x20Service Data - 32-bit UUID ServiceData0x21Service Data - 128-bit UUID ServiceData0xFFManufacturer Specific Data ADManufacturerSpecific
In addition, some specific Manufacturer Specific Data are supported.
Data Type Value Company ID Company Name Format Class 0xFF0x004CApple, Inc. iBeacon IBeacon0xFF0x0105Ubiquitous Computing Technology Corporation ucode Ucode0xFF0x019AT-Engine Forum ucode Ucode
registerBuilder and
registerManufacturerSpecificBuilder can be used to register your
customized parsers for AD structures.
ServiceData has subclasses. The table below lists the supported
data formats.
Service UUID Format Class 0xFEAA(Eddystone)Eddystone UID EddystoneUID0xFEAA(Eddystone)Eddystone URL EddystoneURL0xFEAA(Eddystone)Eddystone TLM EddystoneTLM
payload - A byte array containing of AD structures.offset - The offset from which parsing should be started.length - The length of bytes to be parsed.payload
is null, this method returns null.Copyright © 2016. All rights reserved.