BluetoothSocketException  |  API reference  |  Android Developers (original) (raw)


open class BluetoothSocketException : IOException

kotlin.Any
kotlin.Throwable
java.lang.Exception
java.io.IOException

Thrown when an error occurs during a Bluetooth Socket related exception.

This is currently intended to be thrown for a failure during [BluetoothSocket](/reference/kotlin/android/bluetooth/BluetoothSocket) operations.

Summary

Constants
static Int BLUETOOTH_OFF_FAILURE Error code returned by BluetoothSocket during a socket operation that failed because Bluetooth is turned off.
static Int L2CAP_ACL_FAILURE Error code during connect when there is an ACL connection failure.
static Int L2CAP_CLIENT_SECURITY_FAILURE Error code during connect when security clearance fails on the client during L2CAP connection.
static Int L2CAP_INSUFFICIENT_AUTHENTICATION Error code during connect when authentication fails on the peer device during L2CAP connection.
static Int L2CAP_INSUFFICIENT_AUTHORIZATION Error code during connect when authorization fails on the peer device during L2CAP connection.
static Int L2CAP_INSUFFICIENT_ENCRYPTION Error code during connect for insufficient encryption from the peer device during L2CAP connection.
static Int L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE Error code during connect indicating insufficient encryption key size on the peer device during L2CAP connection.
static Int L2CAP_INVALID_PARAMETERS Error code during connect for invalid parameters from the peer device during L2CAP connection.
static Int L2CAP_INVALID_SOURCE_CID Error code during connect for invalid Channel ID from the peer device during L2CAP connection.
static Int L2CAP_NO_PSM_AVAILABLE Error code during connect when no PSM is available for L2CAP connection.
static Int L2CAP_NO_RESOURCES Error code during connect when no resources are available for L2CAP connection.
static Int L2CAP_SOURCE_CID_ALREADY_ALLOCATED Error code during connect for already allocated Channel ID from the peer device during L2CAP connection.
static Int L2CAP_TIMEOUT Error code during connect when L2CAP connection timeout.
static Int L2CAP_UNACCEPTABLE_PARAMETERS Error code during connect for unacceptable Parameters from the peer device during L2CAP connection.
static Int L2CAP_UNKNOWN Error code returned by BluetoothSocket during a L2CAP-related socket operation that failed for an unknown reason.
static Int NULL_DEVICE Error code during connect when null device attempts to do socket connection.
static Int RPC_FAILURE Error code during connect when a Runtime RPC exception occurs.
static Int SOCKET_CLOSED Error code returned by BluetoothSocket during a socket operation that failed because the socket has been closed.
static Int SOCKET_CONNECTION_FAILURE Error code during connect for generic socket connection failures.
static Int SOCKET_MANAGER_FAILURE Error code returned by BluetoothSocket during a socket operation that failed because socket manager is not available.
static Int UNIX_FILE_SOCKET_CREATION_FAILURE Error code during connect when the UNIX socket connection creation fails.
static Int UNSPECIFIED Error code representing a failure during BluetoothSocket.
Public constructors
BluetoothSocketException(code: Int) Create a BluetoothSocketException with an error code.
BluetoothSocketException(code: Int, msg: String) Create a BluetoothSocketException with an error code and custom error message.
Public methods
open Int getErrorCode() Returns the error code associated to this failure.

Constants

BLUETOOTH_OFF_FAILURE

static val BLUETOOTH_OFF_FAILURE: Int

Error code returned by [BluetoothSocket](/reference/kotlin/android/bluetooth/BluetoothSocket) during a socket operation that failed because Bluetooth is turned off.

Value: 15

L2CAP_ACL_FAILURE

static val L2CAP_ACL_FAILURE: Int

Error code during connect when there is an ACL connection failure.

Value: 2

L2CAP_CLIENT_SECURITY_FAILURE

static val L2CAP_CLIENT_SECURITY_FAILURE: Int

Error code during connect when security clearance fails on the client during L2CAP connection.

Value: 3

L2CAP_INSUFFICIENT_AUTHENTICATION

static val L2CAP_INSUFFICIENT_AUTHENTICATION: Int

Error code during connect when authentication fails on the peer device during L2CAP connection.

Value: 4

static val L2CAP_INSUFFICIENT_AUTHORIZATION: Int

Error code during connect when authorization fails on the peer device during L2CAP connection.

Value: 5

L2CAP_INSUFFICIENT_ENCRYPTION

static val L2CAP_INSUFFICIENT_ENCRYPTION: Int

Error code during connect for insufficient encryption from the peer device during L2CAP connection.

Value: 7

L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE

static val L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE: Int

Error code during connect indicating insufficient encryption key size on the peer device during L2CAP connection.

Value: 6

L2CAP_INVALID_PARAMETERS

static val L2CAP_INVALID_PARAMETERS: Int

Error code during connect for invalid parameters from the peer device during L2CAP connection.

Value: 11

L2CAP_INVALID_SOURCE_CID

static val L2CAP_INVALID_SOURCE_CID: Int

Error code during connect for invalid Channel ID from the peer device during L2CAP connection.

Value: 8

L2CAP_NO_PSM_AVAILABLE

static val L2CAP_NO_PSM_AVAILABLE: Int

Error code during connect when no PSM is available for L2CAP connection.

Value: 13

L2CAP_NO_RESOURCES

static val L2CAP_NO_RESOURCES: Int

Error code during connect when no resources are available for L2CAP connection.

Value: 12

L2CAP_SOURCE_CID_ALREADY_ALLOCATED

static val L2CAP_SOURCE_CID_ALREADY_ALLOCATED: Int

Error code during connect for already allocated Channel ID from the peer device during L2CAP connection.

Value: 9

L2CAP_TIMEOUT

static val L2CAP_TIMEOUT: Int

Error code during connect when L2CAP connection timeout.

Value: 14

L2CAP_UNACCEPTABLE_PARAMETERS

static val L2CAP_UNACCEPTABLE_PARAMETERS: Int

Error code during connect for unacceptable Parameters from the peer device during L2CAP connection.

Value: 10

L2CAP_UNKNOWN

static val L2CAP_UNKNOWN: Int

Error code returned by [BluetoothSocket](/reference/kotlin/android/bluetooth/BluetoothSocket) during a L2CAP-related socket operation that failed for an unknown reason.

Value: 1

NULL_DEVICE

static val NULL_DEVICE: Int

Error code during connect when null device attempts to do socket connection.

Value: 19

RPC_FAILURE

static val RPC_FAILURE: Int

Error code during connect when a Runtime RPC exception occurs.

Value: 20

SOCKET_CLOSED

static val SOCKET_CLOSED: Int

Error code returned by [BluetoothSocket](/reference/kotlin/android/bluetooth/BluetoothSocket) during a socket operation that failed because the socket has been closed.

Value: 17

SOCKET_CONNECTION_FAILURE

static val SOCKET_CONNECTION_FAILURE: Int

Error code during connect for generic socket connection failures.

Value: 18

SOCKET_MANAGER_FAILURE

static val SOCKET_MANAGER_FAILURE: Int

Error code returned by [BluetoothSocket](/reference/kotlin/android/bluetooth/BluetoothSocket) during a socket operation that failed because socket manager is not available.

Value: 16

UNIX_FILE_SOCKET_CREATION_FAILURE

static val UNIX_FILE_SOCKET_CREATION_FAILURE: Int

Error code during connect when the UNIX socket connection creation fails.

Value: 21

UNSPECIFIED

static val UNSPECIFIED: Int

Error code representing a failure during [BluetoothSocket](/reference/kotlin/android/bluetooth/BluetoothSocket). The reason for failure isn't specified.

Value: 0

Public constructors

BluetoothSocketException

BluetoothSocketException(code: Int)

Create a [BluetoothSocketException](#) with an error code. A generic error message is generated based on the code provided.

Parameters
code Int: : error code representing the reason for failure. Value is android.bluetooth.BluetoothSocketException#UNSPECIFIED, android.bluetooth.BluetoothSocketException#L2CAP_UNKNOWN, android.bluetooth.BluetoothSocketException#L2CAP_ACL_FAILURE, android.bluetooth.BluetoothSocketException#L2CAP_CLIENT_SECURITY_FAILURE, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHENTICATION, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHORIZATION, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPTION, android.bluetooth.BluetoothSocketException#L2CAP_INVALID_SOURCE_CID, android.bluetooth.BluetoothSocketException#L2CAP_SOURCE_CID_ALREADY_ALLOCATED, android.bluetooth.BluetoothSocketException#L2CAP_UNACCEPTABLE_PARAMETERS, android.bluetooth.BluetoothSocketException#L2CAP_INVALID_PARAMETERS, android.bluetooth.BluetoothSocketException#L2CAP_NO_RESOURCES, android.bluetooth.BluetoothSocketException#L2CAP_NO_PSM_AVAILABLE, android.bluetooth.BluetoothSocketException#L2CAP_TIMEOUT, android.bluetooth.BluetoothSocketException#BLUETOOTH_OFF_FAILURE, android.bluetooth.BluetoothSocketException#SOCKET_MANAGER_FAILURE, android.bluetooth.BluetoothSocketException#SOCKET_CLOSED, android.bluetooth.BluetoothSocketException#SOCKET_CONNECTION_FAILURE, android.bluetooth.BluetoothSocketException#NULL_DEVICE, android.bluetooth.BluetoothSocketException#RPC_FAILURE, or android.bluetooth.BluetoothSocketException#UNIX_FILE_SOCKET_CREATION_FAILURE

BluetoothSocketException

BluetoothSocketException(
    code: Int,
    msg: String)

Create a [BluetoothSocketException](#) with an error code and custom error message.

Parameters
code Int: : error code representing the reason for failure. Value is android.bluetooth.BluetoothSocketException#UNSPECIFIED, android.bluetooth.BluetoothSocketException#L2CAP_UNKNOWN, android.bluetooth.BluetoothSocketException#L2CAP_ACL_FAILURE, android.bluetooth.BluetoothSocketException#L2CAP_CLIENT_SECURITY_FAILURE, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHENTICATION, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHORIZATION, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPTION, android.bluetooth.BluetoothSocketException#L2CAP_INVALID_SOURCE_CID, android.bluetooth.BluetoothSocketException#L2CAP_SOURCE_CID_ALREADY_ALLOCATED, android.bluetooth.BluetoothSocketException#L2CAP_UNACCEPTABLE_PARAMETERS, android.bluetooth.BluetoothSocketException#L2CAP_INVALID_PARAMETERS, android.bluetooth.BluetoothSocketException#L2CAP_NO_RESOURCES, android.bluetooth.BluetoothSocketException#L2CAP_NO_PSM_AVAILABLE, android.bluetooth.BluetoothSocketException#L2CAP_TIMEOUT, android.bluetooth.BluetoothSocketException#BLUETOOTH_OFF_FAILURE, android.bluetooth.BluetoothSocketException#SOCKET_MANAGER_FAILURE, android.bluetooth.BluetoothSocketException#SOCKET_CLOSED, android.bluetooth.BluetoothSocketException#SOCKET_CONNECTION_FAILURE, android.bluetooth.BluetoothSocketException#NULL_DEVICE, android.bluetooth.BluetoothSocketException#RPC_FAILURE, or android.bluetooth.BluetoothSocketException#UNIX_FILE_SOCKET_CREATION_FAILURE
msg String: : Custom error message associated to the failure. This value cannot be null.

Public methods

getErrorCode

open fun getErrorCode(): Int

Returns the error code associated to this failure.

Return
Int Value is android.bluetooth.BluetoothSocketException#UNSPECIFIED, android.bluetooth.BluetoothSocketException#L2CAP_UNKNOWN, android.bluetooth.BluetoothSocketException#L2CAP_ACL_FAILURE, android.bluetooth.BluetoothSocketException#L2CAP_CLIENT_SECURITY_FAILURE, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHENTICATION, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHORIZATION, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE, android.bluetooth.BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPTION, android.bluetooth.BluetoothSocketException#L2CAP_INVALID_SOURCE_CID, android.bluetooth.BluetoothSocketException#L2CAP_SOURCE_CID_ALREADY_ALLOCATED, android.bluetooth.BluetoothSocketException#L2CAP_UNACCEPTABLE_PARAMETERS, android.bluetooth.BluetoothSocketException#L2CAP_INVALID_PARAMETERS, android.bluetooth.BluetoothSocketException#L2CAP_NO_RESOURCES, android.bluetooth.BluetoothSocketException#L2CAP_NO_PSM_AVAILABLE, android.bluetooth.BluetoothSocketException#L2CAP_TIMEOUT, android.bluetooth.BluetoothSocketException#BLUETOOTH_OFF_FAILURE, android.bluetooth.BluetoothSocketException#SOCKET_MANAGER_FAILURE, android.bluetooth.BluetoothSocketException#SOCKET_CLOSED, android.bluetooth.BluetoothSocketException#SOCKET_CONNECTION_FAILURE, android.bluetooth.BluetoothSocketException#NULL_DEVICE, android.bluetooth.BluetoothSocketException#RPC_FAILURE, or android.bluetooth.BluetoothSocketException#UNIX_FILE_SOCKET_CREATION_FAILURE