ScanResult
class ScanResult : Parcelable
| kotlin.Any | |
| ↳ | android.bluetooth.le.ScanResult |
ScanResult for Bluetooth LE scan.
Summary
| Constants | |
|---|---|
| static Int |
For chained advertisements, indicates that the data contained in this scan result is complete. |
| static Int |
For chained advertisements, indicates that the controller was unable to receive all chained packets and the scan result contains incomplete truncated data. |
| static Int |
Periodic advertising interval is not present in the packet. |
| static Int |
Indicates that the secondary physical layer was not used. |
| static Int |
Advertising Set ID is not present in the packet. |
| static Int |
TX power is not present in the packet. |
| Inherited constants | |
|---|---|
| Public constructors | |
|---|---|
ScanResult(device: BluetoothDevice!, scanRecord: ScanRecord!, rssi: Int, timestampNanos: Long)Constructs a new ScanResult. |
|
ScanResult(device: BluetoothDevice!, eventType: Int, primaryPhy: Int, secondaryPhy: Int, advertisingSid: Int, txPower: Int, rssi: Int, periodicAdvertisingInterval: Int, scanRecord: ScanRecord!, timestampNanos: Long)Constructs a new ScanResult. |
|
| Public methods | |
|---|---|
| Int | |
| Boolean |
Indicates whether some other object is "equal to" this one. |
| Int |
Returns the advertising set id. |
| Int |
Returns the data status. |
| BluetoothDevice! |
Returns the remote Bluetooth device identified by the Bluetooth device address. |
| Int |
Returns the periodic advertising interval in units of 1. |
| Int |
Returns the primary Physical Layer on which this advertisement was received. |
| Int |
getRssi()Returns the received signal strength in dBm. |
| ScanRecord? |
Returns the scan record, which is a combination of advertisement and scan response. |
| Int |
Returns the secondary Physical Layer on which this advertisement was received. |
| Long |
Returns timestamp since boot when the scan record was observed. |
| Int |
Returns the transmit power in dBm. |
| Int |
hashCode() |
| Boolean |
Returns true if this object represents connectable scan result. |
| Boolean |
isLegacy()Returns true if this object represents legacy scan result. |
| String |
toString() |
| Unit |
writeToParcel(dest: Parcel, flags: Int) |
| Properties | |
|---|---|
| static Parcelable.Creator<ScanResult!> | |
Constants
DATA_COMPLETE
static val DATA_COMPLETE: Int
For chained advertisements, indicates that the data contained in this scan result is complete.
Value: 0DATA_TRUNCATED
static val DATA_TRUNCATED: Int
For chained advertisements, indicates that the controller was unable to receive all chained packets and the scan result contains incomplete truncated data.
Value: 2PERIODIC_INTERVAL_NOT_PRESENT
static val PERIODIC_INTERVAL_NOT_PRESENT: Int
Periodic advertising interval is not present in the packet.
Value: 0PHY_UNUSED
static val PHY_UNUSED: Int
Indicates that the secondary physical layer was not used.
Value: 0SID_NOT_PRESENT
static val SID_NOT_PRESENT: Int
Advertising Set ID is not present in the packet.
Value: 255TX_POWER_NOT_PRESENT
static val TX_POWER_NOT_PRESENT: Int
TX power is not present in the packet.
Value: 127Public constructors
ScanResult
ScanResult(
device: BluetoothDevice!,
scanRecord: ScanRecord!,
rssi: Int,
timestampNanos: Long)
Deprecated: use ScanResult(android.bluetooth.BluetoothDevice,int,int,int,int,int,int,int,android.bluetooth.le.ScanRecord,long)
Constructs a new ScanResult.
| Parameters | |
|---|---|
device |
BluetoothDevice!: Remote Bluetooth device found. |
scanRecord |
ScanRecord!: Scan record including both advertising data and scan response data. |
rssi |
Int: Received signal strength. |
timestampNanos |
Long: Timestamp at which the scan result was observed. |
ScanResult
ScanResult(
device: BluetoothDevice!,
eventType: Int,
primaryPhy: Int,
secondaryPhy: Int,
advertisingSid: Int,
txPower: Int,
rssi: Int,
periodicAdvertisingInterval: Int,
scanRecord: ScanRecord!,
timestampNanos: Long)
Constructs a new ScanResult.
| Parameters | |
|---|---|
device |
BluetoothDevice!: Remote Bluetooth device found. |
eventType |
Int: Event type. |
primaryPhy |
Int: Primary advertising phy. |
secondaryPhy |
Int: Secondary advertising phy. |
advertisingSid |
Int: Advertising set ID. |
txPower |
Int: Transmit power. |
rssi |
Int: Received signal strength. |
periodicAdvertisingInterval |
Int: Periodic advertising interval. |
scanRecord |
ScanRecord!: Scan record including both advertising data and scan response data. |
timestampNanos |
Long: Timestamp at which the scan result was observed. |
Public methods
describeContents
fun describeContents(): Int
| Return | |
|---|---|
Int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR |
equals
fun equals(other: Any?): Boolean
Indicates whether some other object is "equal to" this one.
The equals method implements an equivalence relation on non-null object references:
- It is reflexive: for any non-null reference value
x,x.equals(x)should returntrue. - It is symmetric: for any non-null reference values
xandy,x.equals(y)should returntrueif and only ify.equals(x)returnstrue. - It is transitive: for any non-null reference values
x,y, andz, ifx.equals(y)returnstrueandy.equals(z)returnstrue, thenx.equals(z)should returntrue. - It is consistent: for any non-null reference values
xandy, multiple invocations ofx.equals(y)consistently returntrueor consistently returnfalse, provided no information used inequalscomparisons on the objects is modified. - For any non-null reference value
x,x.equals(null)should returnfalse.
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| Parameters | |
|---|---|
obj |
This value may be null. |
| Return | |
|---|---|
Boolean |
true if this object is the same as the obj argument; false otherwise. |
getAdvertisingSid
fun getAdvertisingSid(): Int
Returns the advertising set id. May return ScanResult.SID_NOT_PRESENT if no set id was is present.
getDataStatus
fun getDataStatus(): Int
Returns the data status. Can be one of ScanResult.DATA_COMPLETE or android.bluetooth.le.ScanResult#DATA_TRUNCATED.
getDevice
fun getDevice(): BluetoothDevice!
Returns the remote Bluetooth device identified by the Bluetooth device address. If the device is bonded, calling BluetoothDevice.getAddress on the object returned by this method will return the address that was originally bonded with (either identity address or random address).
getPeriodicAdvertisingInterval
fun getPeriodicAdvertisingInterval(): Int
Returns the periodic advertising interval in units of 1.25ms. Valid range is 6 (7.5ms) to 65536 (81918.75ms). A value of ScanResult.PERIODIC_INTERVAL_NOT_PRESENT means periodic advertising interval is not present.
getPrimaryPhy
fun getPrimaryPhy(): Int
Returns the primary Physical Layer on which this advertisement was received. Can be one of BluetoothDevice.PHY_LE_1M or BluetoothDevice.PHY_LE_CODED.
getRssi
fun getRssi(): Int
Returns the received signal strength in dBm. The valid range is [-127, 126].
getScanRecord
fun getScanRecord(): ScanRecord?
Returns the scan record, which is a combination of advertisement and scan response.
| Return | |
|---|---|
ScanRecord? |
This value may be null. |
getSecondaryPhy
fun getSecondaryPhy(): Int
Returns the secondary Physical Layer on which this advertisement was received. Can be one of BluetoothDevice.PHY_LE_1M, BluetoothDevice.PHY_LE_2M, android.bluetooth.BluetoothDevice#PHY_LE_CODED or ScanResult.PHY_UNUSED - if the advertisement was not received on a secondary physical channel.
getTimestampNanos
fun getTimestampNanos(): Long
Returns timestamp since boot when the scan record was observed.
getTxPower
fun getTxPower(): Int
Returns the transmit power in dBm. Valid range is [-127, 126]. A value of android.bluetooth.le.ScanResult#TX_POWER_NOT_PRESENT indicates that the TX power is not present.
isConnectable
fun isConnectable(): Boolean
Returns true if this object represents connectable scan result.
isLegacy
fun isLegacy(): Boolean
Returns true if this object represents legacy scan result. Legacy scan results do not contain advanced advertising information as specified in the Bluetooth Core Specification v5.
toString
fun toString(): String
| Return | |
|---|---|
String |
a string representation of the object. |
writeToParcel
fun writeToParcel(
dest: Parcel,
flags: Int
): Unit
| Parameters | |
|---|---|
dest |
Parcel: The Parcel in which the object should be written. This value cannot be null. |
flags |
Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |