apidocs / com.nimmsta.core.android.bluetooth / DevicePairingManager

DevicePairingManager

class DevicePairingManager

This class handles all known devices and the pairing with the app. It provides methods to pair and unpair. For concurrent actions it will do last action wins, but will sort out duplicates. It will also store devices that are currently paired throughout relaunch of the application to disconnect died devices.

Example:

pairAsync() pairAsync() unpairAsync() pairAsync() will pair once, unpair once and pair again. After all the device is paired.

Types

PairableDevice

Represents one device with its state.

inner class PairableDevice

Constructors

<init>

This class handles all known devices and the pairing with the app. It provides methods to pair and unpair. For concurrent actions it will do last action wins, but will sort out duplicates. It will also store devices that are currently paired throughout relaunch of the application to disconnect died devices.

DevicePairingManager(context: Context)

Properties

protocolLog

val protocolLog: String

Functions

getPairedAddresses

Returns currently paired device addresses.

fun getPairedAddresses(): List<BluetoothDeviceMacAddress>

pairAsync

Pairs the bluetooth device with the given address asynchronously. Will unpair first if previous pair was not successful. Will remember that the device was paired by this application.

fun pairAsync(device: BluetoothDeviceMacAddress, startedPairing: ((Unit) -> Unit)? = null): Task<Unit>

unpairAsync

Unpairs the bluetooth device with the given address asynchronously. Will remove the device from devices known to this application.

fun unpairAsync(device: BluetoothDeviceMacAddress): Task<Unit>

Companion Object Properties

AFTER_OPERATION_DELAY

val AFTER_OPERATION_DELAY: TimeSpan

CHECK_PAIRED_DELAY

val CHECK_PAIRED_DELAY: TimeSpan

MAX_LOGS_TO_STORE

const val MAX_LOGS_TO_STORE: Int

PAIRED_DEVICES_KEY

const val PAIRED_DEVICES_KEY: String

PAIRING_TIMEOUT

val PAIRING_TIMEOUT: TimeSpan

TAG

val TAG: String