BleCharacteristicException

class BleCharacteristicException(message: String, val gattStatus: Int? = null, val characteristicUuid: String? = null, val operation: BleCharacteristicException.CharacteristicOperation? = null) : BleException

Exception thrown when a characteristic operation (read, write, or notify) fails.

This exception provides detailed information about which operation failed and on which characteristic, making it easier to diagnose and handle specific failures.

Common Causes

  • Characteristic does not support the requested operation

  • Insufficient encryption or authentication

  • Invalid value length

  • Characteristic not found

  • Device disconnected during operation

Usage Example

when (error) {
is BleCharacteristicException -> {
val opName = error.operation?.name ?: "UNKNOWN"
Log.e("BLE", "$opName failed on ${error.characteristicUuid}")

when (error.operation) {
CharacteristicOperation.READ -> handleReadFailure()
CharacteristicOperation.WRITE -> handleWriteFailure()
CharacteristicOperation.NOTIFY -> handleNotifyFailure()
null -> handleUnknownFailure()
}
}
}

See also

Constructors

Link copied to clipboard
constructor(message: String, gattStatus: Int? = null, characteristicUuid: String? = null, operation: BleCharacteristicException.CharacteristicOperation? = null)

Types

Link copied to clipboard

Enumeration of characteristic operations that can fail.

Properties

Link copied to clipboard
open val cause: Throwable?
Link copied to clipboard

The UUID of the characteristic that failed, as a string.

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

The GATT status code from the operation callback.

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

The type of operation that failed.

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