iOS Developer Library

Developer

CoreBluetooth Framework Reference Core Bluetooth Constants Reference

Options
Deployment Target:

On This Page
Language:

Core Bluetooth Constants Reference

Inherits From


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import CoreBluetooth

Objective-C

@import CoreBluetooth;

This document describes the constants found in the Core Bluetooth framework.

Constants

  • The domain for Core Bluetooth errors.

    Declaration

    Swift

    let CBErrorDomain: String

    Objective-C

    NSString *const CBErrorDomain;

    Constants

    • CBErrorDomain

      CBErrorDomain

      The domain for Core Bluetooth errors. This value is used in the NSError class.

      Available in iOS 5.0 and later

  • The possible errors returned during Bluetooth low energy transactions.

    Declaration

    Swift

    enum CBError : Int { case Unknown case InvalidParameters case InvalidHandle case NotConnected case OutOfSpace case OperationCancelled case ConnectionTimeout case PeripheralDisconnected case UUIDNotAllowed case AlreadyAdvertising case ConnectionFailed }

    Objective-C

    typedef enum { CBErrorUnknown = 0, CBErrorInvalidParameters = 1, CBErrorInvalidHandle = 2, CBErrorNotConnected = 3, CBErrorOutOfSpace = 4, CBErrorOperationCancelled = 5, CBErrorConnectionTimeout = 6, CBErrorPeripheralDisconnected = 7, CBErrorUUIDNotAllowed = 8, CBErrorAlreadyAdvertising = 9, CBErrorConnectionFailed = 10 } CBError;

    Constants

    • Unknown

      CBErrorUnknown

      An unknown error occurred.

      Available in iOS 5.0 and later

    • InvalidParameters

      CBErrorInvalidParameters

      The specified parameters are invalid.

      Available in iOS 6.0 and later

    • InvalidHandle

      CBErrorInvalidHandle

      The specified attribute handle is invalid.

      Available in iOS 6.0 and later

    • NotConnected

      CBErrorNotConnected

      The device is not currently connected.

      Available in iOS 6.0 and later

    • OutOfSpace

      CBErrorOutOfSpace

      The device has run out of space to complete the intended operation.

      Available in iOS 6.0 and later

    • OperationCancelled

      CBErrorOperationCancelled

      The operation is canceled.

      Available in iOS 6.0 and later

    • ConnectionTimeout

      CBErrorConnectionTimeout

      The connection timed out.

      Available in iOS 6.0 and later

    • PeripheralDisconnected

      CBErrorPeripheralDisconnected

      The peripheral disconnected.

      Available in iOS 6.0 and later

    • UUIDNotAllowed

      CBErrorUUIDNotAllowed

      The specified UUID is not permitted.

      Available in iOS 6.0 and later

    • AlreadyAdvertising

      CBErrorAlreadyAdvertising

      The peripheral is already advertising.

      Available in iOS 6.0 and later

    • ConnectionFailed

      CBErrorConnectionFailed

      The connection failed.

      Available in iOS 7.1 and later

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 5.0 and later

  • The domain for Core Bluetooth ATT errors.

    Declaration

    Swift

    let CBATTErrorDomain: String

    Objective-C

    NSString *const CBATTErrorDomain;

    Constants

    • CBATTErrorDomain

      CBATTErrorDomain

      The domain for Core Bluetooth ATT errors. This value is used in the NSError class.

      Available in iOS 5.0 and later

  • The possible errors returned by a GATT server (a remote peripheral) during Bluetooth low energy ATT transactions.

    Declaration

    Swift

    enum CBATTError : Int { case Success case InvalidHandle case ReadNotPermitted case WriteNotPermitted case InvalidPdu case InsufficientAuthentication case RequestNotSupported case InvalidOffset case InsufficientAuthorization case PrepareQueueFull case AttributeNotFound case AttributeNotLong case InsufficientEncryptionKeySize case InvalidAttributeValueLength case UnlikelyError case InsufficientEncryption case UnsupportedGroupType case InsufficientResources }

    Objective-C

    typedef enum { CBATTErrorSuccess = 0x00, CBATTErrorInvalidHandle = 0x01, CBATTErrorReadNotPermitted = 0x02, CBATTErrorWriteNotPermitted = 0x03, CBATTErrorInvalidPdu = 0x04, CBATTErrorInsufficientAuthentication = 0x05, CBATTErrorRequestNotSupported = 0x06, CBATTErrorInvalidOffset = 0x07, CBATTErrorInsufficientAuthorization = 0x08, CBATTErrorPrepareQueueFull = 0x09, CBATTErrorAttributeNotFound = 0x0A, CBATTErrorAttributeNotLong = 0x0B, CBATTErrorInsufficientEncryptionKeySize = 0x0C, CBATTErrorInvalidAttributeValueLength = 0x0D, CBATTErrorUnlikelyError = 0x0E, CBATTErrorInsufficientEncryption = 0x0F, CBATTErrorUnsupportedGroupType = 0x10, CBATTErrorInsufficientResources = 0x11, } CBATTError;

    Constants

    • Success

      CBATTErrorSuccess

      The ATT command or request successfully completed.

      Available in iOS 6.0 and later

    • InvalidHandle

      CBATTErrorInvalidHandle

      The attribute handle is invalid on this peripheral.

      Available in iOS 5.0 and later

    • ReadNotPermitted

      CBATTErrorReadNotPermitted

      The attribute’s value cannot be read.

      Available in iOS 5.0 and later

    • WriteNotPermitted

      CBATTErrorWriteNotPermitted

      The attribute’s value cannot be written.

      Available in iOS 5.0 and later

    • InvalidPdu

      CBATTErrorInvalidPdu

      The attribute Protocol Data Unit (PDU) or “message” is invalid.

      Available in iOS 5.0 and later

    • InsufficientAuthentication

      CBATTErrorInsufficientAuthentication

      The attribute requires authentication before its value can be read or written.

      Available in iOS 5.0 and later

    • RequestNotSupported

      CBATTErrorRequestNotSupported

      The attribute server does not support the request received by the client.

      Available in iOS 5.0 and later

    • InvalidOffset

      CBATTErrorInvalidOffset

      The specified offset value was past the end of the attribute’s value.

      Available in iOS 5.0 and later

    • InsufficientAuthorization

      CBATTErrorInsufficientAuthorization

      The attribute requires authorization before its value can be read or written.

      Available in iOS 5.0 and later

    • PrepareQueueFull

      CBATTErrorPrepareQueueFull

      The prepare queue is full, because too many prepare write requests have been queued.

      Available in iOS 5.0 and later

    • AttributeNotFound

      CBATTErrorAttributeNotFound

      The attribute is not found within the specified attribute handle range.

      Available in iOS 5.0 and later

    • AttributeNotLong

      CBATTErrorAttributeNotLong

      The attribute cannot be read or written using the ATT read blob request.

      Available in iOS 5.0 and later

    • InsufficientEncryptionKeySize

      CBATTErrorInsufficientEncryptionKeySize

      The encryption key size used for encrypting this link is insufficient.

      Available in iOS 5.0 and later

    • InvalidAttributeValueLength

      CBATTErrorInvalidAttributeValueLength

      The length of the attribute’s value is invalid for the intended operation.

      Available in iOS 5.0 and later

    • UnlikelyError

      CBATTErrorUnlikelyError

      The ATT request has encountered an unlikely error and therefore could not be completed.

      Available in iOS 5.0 and later

    • InsufficientEncryption

      CBATTErrorInsufficientEncryption

      The attribute requires encryption before its value can be read or written.

      Available in iOS 5.0 and later

    • UnsupportedGroupType

      CBATTErrorUnsupportedGroupType

      The attribute type is not a supported grouping attribute as defined by a higher-layer specification.

      Available in iOS 5.0 and later

    • InsufficientResources

      CBATTErrorInsufficientResources

      Resources are insufficient to complete the ATT request.

      Available in iOS 5.0 and later

    Discussion

    These error constants are based on the Bluetooth ATT error codes, defined in the Bluetooth 4.0 specification. For more information about these errors, see the Bluetooth 4.0 specification, Volume 3, Part F, Section 3.4.1.1.

    Import Statement

    Objective-C

    @import CoreBluetooth;

    Swift

    import CoreBluetooth

    Availability

    Available in iOS 5.0 and later