BluetoothRepository

@Singleton
class BluetoothRepository @Inject constructor(application: Application, bluetoothBroadcastReceiverLazy: Lazy<BluetoothBroadcastReceiver>, dispatchers: CoroutineDispatchers, processLifecycle: Lifecycle, centralManager: CentralManager)(source)

Repository responsible for maintaining and updating the state of Bluetooth availability.

Constructors

Link copied to clipboard
@Inject
constructor(application: Application, bluetoothBroadcastReceiverLazy: Lazy<BluetoothBroadcastReceiver>, dispatchers: CoroutineDispatchers, processLifecycle: Lifecycle, centralManager: CentralManager)

Properties

Link copied to clipboard
val isScanning: StateFlow<Boolean>
Link copied to clipboard
val scannedDevices: StateFlow<List<Peripheral>>
Link copied to clipboard
val state: StateFlow<BluetoothState>

Functions

Link copied to clipboard
suspend fun bond(peripheral: Peripheral)

Initiates bonding with the given peripheral. This is a suspending function that completes when the bonding process is finished. After successful bonding, the repository's state is refreshed to include the new bonded device.

Link copied to clipboard
fun isValid(bleAddress: String): Boolean
Link copied to clipboard
Link copied to clipboard
fun startScan()

Starts a BLE scan for Meshtastic devices. The results are published to the scannedDevices flow.

Link copied to clipboard
fun stopScan()

Stops the currently active BLE scan.