class ScanResult


Represents a scan result for Bluetooth LE scan.

The ScanResult class is used by Bluetooth LE applications to scan for and discover Bluetooth LE devices. When a Bluetooth LE application scans for devices, it will receive a list of ScanResult objects that contain information about the scanned devices. The application can then use this information to determine which devices it wants to connect to.

Summary

Constants

const Int

Periodic advertising interval is not present in the packet.

Public functions

ByteArray?

Returns the manufacturer specific data associated with the manufacturer id.

ByteArray?
getServiceData(serviceUuid: UUID)

Returns the service data associated with the service UUID.

Boolean

Checks if this object represents a connectable scan result.

Public properties

BluetoothDevice

Remote Bluetooth device found.

BluetoothAddress

Bluetooth address for the remote device found.

Long

Returns the periodic advertising interval in milliseconds ranging from 7.5ms to 81918.75ms A value of PERIODIC_INTERVAL_NOT_PRESENT means periodic advertising interval is not present.

Int

Returns the received signal strength in dBm.

Map<ParcelUuidByteArray>

Returns a map of service UUID and its corresponding service data.

List<ParcelUuid>

Returns a list of service solicitation UUIDs within the advertisement that are used to identify the Bluetooth GATT services.

List<UUID>

A list of service UUIDs within advertisement that are used to identify the bluetooth GATT services.

Long

Device timestamp when the advertisement was last seen.

Constants

PERIODIC_INTERVAL_NOT_PRESENT

const val PERIODIC_INTERVAL_NOT_PRESENTInt

Periodic advertising interval is not present in the packet.

Public functions

getManufacturerSpecificData

Added in 1.0.0-alpha02
fun getManufacturerSpecificData(manufacturerId: Int): ByteArray?

Returns the manufacturer specific data associated with the manufacturer id.

Parameters
manufacturerId: Int

The manufacturer id of the scanned device

Returns
ByteArray?

the manufacturer specific data associated with the manufacturer id, or @{code null} if the manufacturer specific data is not present

getServiceData

Added in 1.0.0-alpha02
fun getServiceData(serviceUuid: UUID): ByteArray?

Returns the service data associated with the service UUID.

Parameters
serviceUuid: UUID

The service UUID of the service data

Returns
ByteArray?

the service data associated with the specified service UUID, or null if the service UUID is not found

isConnectable

Added in 1.0.0-alpha02
fun isConnectable(): Boolean

Checks if this object represents a connectable scan result.

Returns
Boolean

{@code true} if the scanned device is connectable.

Please note that this will return {@code true} on versions before android.os.Build.VERSION_CODES.Q.

Public properties

device

Added in 1.0.0-alpha02
val deviceBluetoothDevice

Remote Bluetooth device found.

deviceAddress

Added in 1.0.0-alpha02
val deviceAddressBluetoothAddress

Bluetooth address for the remote device found.

periodicAdvertisingInterval

Added in 1.0.0-alpha02
val periodicAdvertisingIntervalLong

Returns the periodic advertising interval in milliseconds ranging from 7.5ms to 81918.75ms A value of PERIODIC_INTERVAL_NOT_PRESENT means periodic advertising interval is not present.

Please note that this will return PERIODIC_INTERVAL_NOT_PRESENT on versions before android.os.Build.VERSION_CODES.Q.

rssi

Added in 1.0.0-alpha02
val rssiInt

Returns the received signal strength in dBm. The valid range is -127, 126.

serviceData

Added in 1.0.0-alpha02
val serviceDataMap<ParcelUuidByteArray>

Returns a map of service UUID and its corresponding service data.

serviceSolicitationUuids

Added in 1.0.0-alpha02
val serviceSolicitationUuidsList<ParcelUuid>

Returns a list of service solicitation UUIDs within the advertisement that are used to identify the Bluetooth GATT services.

Please note that this will return an emptyList() on versions before android.os.Build.VERSION_CODES.Q.

serviceUuids

Added in 1.0.0-alpha02
val serviceUuidsList<UUID>

A list of service UUIDs within advertisement that are used to identify the bluetooth GATT services.

timestampNanos

Added in 1.0.0-alpha02
val timestampNanosLong

Device timestamp when the advertisement was last seen.