BlePermissionException

class BlePermissionException(message: String, val missingPermissions: List<String> = emptyList(), val gattStatus: Int? = null) : BleException

Exception thrown when required Android permissions for BLE operations are missing.

Starting with Android 12 (API 31), BLE operations require runtime permissions from the android.permission.BLUETOOTH_* family. This exception is thrown when an operation is attempted without the necessary permissions.

Required Permissions

  • BLUETOOTH_SCAN - Required for scanning (Android 12+)

  • BLUETOOTH_CONNECT - Required for connecting and GATT operations (Android 12+)

  • BLUETOOTH_ADVERTISE - Required for advertising (Android 12+)

  • ACCESS_FINE_LOCATION - Required for scanning on older Android versions

Usage Example

when (error) {
is BlePermissionException -> {
Log.e("BLE", "Missing permissions: ${error.missingPermissions}")
// Request the missing permissions
requestPermissions(error.missingPermissions.toTypedArray())
}
}

See also

Constructors

Link copied to clipboard
constructor(message: String, missingPermissions: List<String> = emptyList(), gattStatus: Int? = null)

Properties

Link copied to clipboard
open val cause: Throwable?
Link copied to clipboard
open override val gattStatus: Int? = null

The GATT status code, typically null for permission errors.

Link copied to clipboard
open val message: String?
Link copied to clipboard

A list of permission strings that are required but not granted.

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard