BleManager

Central manager for Bluetooth Low Energy (BLE) operations.

This singleton class provides a unified interface for scanning, connecting to, and managing BLE devices. It handles the lifecycle of BLE connections and ensures proper resource management across the application.

Usage:

val bleManager = BleManager.getInstance(context)
bleManager.scanDevices().collect { device ->
// Handle discovered device
}

See also

Types

Link copied to clipboard
object Companion

Companion object providing singleton access to BleManager.

Functions

Link copied to clipboard

Establishes a connection to the specified BLE device.

Link copied to clipboard

Disconnects from the specified BLE device and removes it from active connections.

Link copied to clipboard

Disconnects from all connected BLE devices and clears the connection registry.

Link copied to clipboard
@RequiresApi(value = 31)
suspend fun hasPermissions(): Boolean

Checks if the application has all necessary permissions for BLE operations.

Link copied to clipboard

Scans for nearby BLE devices and emits discovered devices through a Flow.