BleConnectionException

class BleConnectionException(message: String, val gattStatus: Int? = null, val deviceAddress: String? = null) : BleException

Exception thrown when a BLE connection attempt fails or an existing connection is lost.

This exception is used for errors that occur during:

  • Initial connection establishment

  • Connection state changes

  • Unexpected disconnections

Common Causes

  • Device out of range

  • Device powered off

  • Too many connected devices

  • GATT server unavailable

  • Connection timeout

Usage Example

when (error) {
is BleConnectionException -> {
Log.e("BLE", "Connection failed to ${error.deviceAddress}")
error.gattStatus?.let { status ->
Log.e("BLE", "GATT status: $status")
}
}
}

See also

Constructors

Link copied to clipboard
constructor(message: String, gattStatus: Int? = null, deviceAddress: String? = null)

Properties

Link copied to clipboard
open val cause: Throwable?
Link copied to clipboard
val deviceAddress: String? = null

The MAC address of the device that failed to connect.

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

The GATT status code from the connection callback, if available.

Link copied to clipboard
open val message: String?

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