public final class ScanRecord extends Object
Modifier and Type | Method and Description |
---|---|
int |
getAdvertiseFlags()
Returns the advertising flags indicating the discoverable mode and capability of the device.
|
byte[] |
getBytes()
Returns raw bytes of scan record.
|
String |
getDeviceName()
Returns the local name of the BLE device.
|
SparseArray<byte[]> |
getManufacturerSpecificData()
Returns a sparse array of manufacturer identifier and its corresponding manufacturer specific
data.
|
byte[] |
getManufacturerSpecificData(int manufacturerId)
Returns the manufacturer specific data associated with the manufacturer id.
|
Map<ParcelUuid,byte[]> |
getServiceData()
Returns a map of service UUID and its corresponding service data.
|
byte[] |
getServiceData(ParcelUuid serviceDataUuid)
Returns the service data byte array associated with the
serviceUuid . |
List<ParcelUuid> |
getServiceUuids()
Returns a list of service UUIDs within the advertisement that are used to identify the
bluetooth GATT services.
|
int |
getTxPowerLevel()
Returns the transmission power level of the packet in dBm.
|
static ScanRecord |
parseFromBytes(byte[] scanRecord)
Parse scan record bytes to
ScanRecord . |
String |
toString()
Returns a string representation of the object.
|
public int getAdvertiseFlags()
public List<ParcelUuid> getServiceUuids()
public SparseArray<byte[]> getManufacturerSpecificData()
public byte[] getManufacturerSpecificData(int manufacturerId)
null
if the manufacturerId
is not found.public Map<ParcelUuid,byte[]> getServiceData()
public byte[] getServiceData(ParcelUuid serviceDataUuid)
serviceUuid
. Returns
null
if the serviceDataUuid
is not found.public int getTxPowerLevel()
Integer.MIN_VALUE
if the field is not set. This value can be used to calculate the path loss of a received
packet using the following equation:
pathloss = txPowerLevel - rssi
public String getDeviceName()
public byte[] getBytes()
public static ScanRecord parseFromBytes(byte[] scanRecord)
ScanRecord
.
The format is defined in Bluetooth 4.1 specification, Volume 3, Part C, Section 11 and 18.
All numerical multi-byte entities and values shall use little-endian byte order.
scanRecord
- The scan record of Bluetooth LE advertisement and/or scan response.public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())