-
public final class BluetoothPeripheralController
BluetoothPeripheralController is the primary interface for detecting and reading from Bluetooth peripherals. All peripheral updates are given to the peripheral controller's interface, BluetoothPeripheralControllerListener. More than one BluetoothPeripheralController may be instanced at a time, but each controller only performs one operation at a time. Any current operations must finish or be cancelled before a new operation can be started. The two possible operations are .pairPeripheral and .readFromPeripheral.
If the BluetoothPeripheral has "requiresPairing" set to true, then you must first call pairPeripheral: to ensure that we are able to communicate with the peripheral and to do any necessary pairing. When you call .pairPeripheral, you should then present to the user the . When the (BluetoothPeripheralController, callback is called, you can assume all pairing has been done and it is now safe to call .readFromPeripheral.
To get a reading from a peripheral, call .readFromPeripheral and pass in the BluetoothPeripheral object that you want to take a reading from. The reading operation will have multiple callbacks at different stages that are reported to the BluetoothPeripheralControllerListener. When the Record object is returned via callback, it is also simultaneously uploaded to Validic. Do not submit these records to Validic as they have already been submitted.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
BluetoothPeripheralController.Companion
-
Constructor Summary
Constructors Constructor Description BluetoothPeripheralController(CoroutineScope scope)
BluetoothPeripheralController()
-
Method Summary
Modifier and Type Method Description final Boolean
pairPeripheral(BluetoothPeripheral peripheral, BluetoothPeripheralControllerListener listener)
Scans for a BluetoothPeripheral and enqueues a PairRequest to the first BluetoothDevice it finds final Boolean
readFromPeripheral(BluetoothPeripheral peripheral, BluetoothPeripheralControllerListener listener)
Scans for a BluetoothPeripheral and enqueues a ReadRequest for the first device it finds that matchers the BluetoothPeripheral's profile final Unit
cancel()
Cancel the current operation final Boolean
operationInProgress()
Determines if a read or pair operation is currently in progress If an operation is in progress, it will need to be cancelled before a new operation can be started. -
-
Method Detail
-
pairPeripheral
final Boolean pairPeripheral(BluetoothPeripheral peripheral, BluetoothPeripheralControllerListener listener)
Scans for a BluetoothPeripheral and enqueues a PairRequest to the first BluetoothDevice it finds
- Parameters:
peripheral
- the BluetoothPeripheral to find
-
readFromPeripheral
final Boolean readFromPeripheral(BluetoothPeripheral peripheral, BluetoothPeripheralControllerListener listener)
Scans for a BluetoothPeripheral and enqueues a ReadRequest for the first device it finds that matchers the BluetoothPeripheral's profile
-
operationInProgress
final Boolean operationInProgress()
Determines if a read or pair operation is currently in progress If an operation is in progress, it will need to be cancelled before a new operation can be started.
-
-
-
-