SWRU271I October   2010  – January 2020 CC2540 , CC2540T , CC2541 , CC2541-Q1 , CC2640R2F

 

  1.   Preface
    1.     Trademarks
    2.     Related Documentation
  2. 1Overview
    1. 1.1 Support Note
    2. 1.2 Introduction
    3. 1.3 Bluetooth Low Energy Protocol Stack Basics
  3. 2The TI Bluetooth Low Energy Software Development Platform
    1. 2.1 Overview
    2. 2.2 Configurations
    3. 2.3 Projects
    4. 2.4 Software Overview
  4. 3The Operating System Abstraction Layer (OSAL)
    1. 3.1 Overview
    2. 3.2 Task Initialization
    3. 3.3 Task Events and Event Processing
    4. 3.4 Heap Manager
    5. 3.5 OSAL Messages
  5. 4The Application and Profiles
    1. 4.1 Overview
    2. 4.2 Project Overview
    3. 4.3 Start-up in main()
    4. 4.4 Application Initialization
    5. 4.5 Event Processing
      1. 4.5.1 Periodic Event
      2. 4.5.2 OSAL Messages
    6. 4.6 Callbacks
    7. 4.7 Complete Attribute Table
    8. 4.8 Additional Sample Projects
  6. 5The Bluetooth Low Energy Protocol Stack
    1. 5.1 Overview
    2. 5.2 Generic Access Profile (GAP)
      1. 5.2.1 Overview
        1. 5.2.1.1 Connection Parameters
        2. 5.2.1.2 Effective Connection Interval
        3. 5.2.1.3 Connection Parameter Considerations
        4. 5.2.1.4 Connection Parameter Update
        5. 5.2.1.5 Connection Termination
      2. 5.2.2 GAP Abstraction
      3. 5.2.3 Configuring the GAP Layer
    3. 5.3 GAPRole Task
      1. 5.3.1 Peripheral Role
      2. 5.3.2 Central Role
    4. 5.4 Gap Bond Manager (GAPBondMgr)
      1. 5.4.1 Overview of Bluetooth Low Energy Security
      2. 5.4.2 Using the GapBondMgr Profile
      3. 5.4.3 GAPBondMgr Examples for Various Security Modes
        1. 5.4.3.1 Pairing Disabled
        2. 5.4.3.2 Just Works Pairing Without Bonding
        3. 5.4.3.3 Just Works Pairing With Bonding Enabled
        4. 5.4.3.4 Authenticated Pairing
        5. 5.4.3.5 Authenticated Pairing With Bonding Enabled
    5. 5.5 Generic Attribute Profile (GATT)
      1. 5.5.1 GATT Characteristics and Attributes
      2. 5.5.2 GATT Services and Profile
      3. 5.5.3 GATT Client Abstraction
        1. 5.5.3.1 Using the GATT Layer Directly
      4. 5.5.4 GATT Server Abstraction
        1. 5.5.4.1 GATTServApp Module
          1. 5.5.4.1.1 Building Up the Attribute Table
        2. 5.5.4.2 Profile Architecture
          1. 5.5.4.2.1 Attribute Table Definition
            1. 5.5.4.2.1.1 Service Declaration
            2. 5.5.4.2.1.2 Characteristic Declaration
            3. 5.5.4.2.1.3 Characteristic Value
            4. 5.5.4.2.1.4 Client Characteristic Configuration
          2. 5.5.4.2.2 Add Service Function
          3. 5.5.4.2.3 Register Application Callback Function
          4. 5.5.4.2.4 Read and Write Callback Functions
            1. 5.5.4.2.4.1 Read Request from A GATT Client
            2. 5.5.4.2.4.2 Write Request From Client
          5. 5.5.4.2.5 Get and Set Functions
    6. 5.6 L2CAP
    7. 5.7 HCI
      1. 5.7.1 HCI Extension Vendor-Specific Commands
      2. 5.7.2 Receiving HCI Extension Events in the Application
    8. 5.8 Library Files
  7. 6Drivers
    1. 6.1  Overview
    2. 6.2  ADC
    3. 6.3  AES
    4. 6.4  LCD
    5. 6.5  LED
    6. 6.6  KEY
    7. 6.7  DMA
    8. 6.8  UART and SPI
    9. 6.9  Other Peripherals
    10. 6.10 Simple NV (SNV)
  8. 7Creating a Custom Bluetooth Low Energy Application
    1. 7.1 Overview
    2. 7.2 Configuring the Bluetooth Low Energy Stack
    3. 7.3 Define Bluetooth Low Energy Behavior
    4. 7.4 Define Application Tasks
    5. 7.5 Configure Hardware Peripherals
    6. 7.6 Configuring Parameters for Custom Hardware
      1. 7.6.1 Board File
      2. 7.6.2 Adjusting for 32-MHz Crystal Stabilization Time
      3. 7.6.3 Setting the Sleep Clock Accuracy
    7. 7.7 Software Considerations
      1. 7.7.1 Memory Management for GATT Notifications and Indications
      2. 7.7.2 Limit Application Processing During Bluetooth Low Energy Activity
      3. 7.7.3 Global Interrupts
  9. 8Development and Debugging
    1. 8.1 Overview
    2. 8.2 IAR Overview
    3. 8.3 Using IAR Embedded Workbench
      1. 8.3.1 Open an Existing Project
      2. 8.3.2 Project Options, Configurations, and Defined Symbols
      3. 8.3.3 Building and Debugging a Project
      4. 8.3.4 Linker Map File
  10. 9General Information
    1. 9.1 Overview
    2. 9.2 Porting From BLE-Stack 1.5.0 to 1.5.1
    3. 9.3 Porting From BLE-Stack 1.4.2 to 1.5.0
    4. 9.4 Porting From Earlier BLE-Stack Versions
      1. 9.4.1 Porting BLEv1.4.1 Projects to BLEv1.4.2
      2. 9.4.2 Porting BLEv1.4.0 Projects to BLEv1.4.1
        1. 9.4.2.1 Project Porting Directions
        2. 9.4.2.2 API Changes
        3. 9.4.2.3 Typedef Changes
        4. 9.4.2.4 Structure Changes
          1. 9.4.2.4.1 Array Elements Changed to Pointers
          2. 9.4.2.4.2 Additional Fields in Key Distribution Strucutre
        5. 9.4.2.5 Default Value of HAL Components
        6. 9.4.2.6 Allocating Memory for Over-the-Air Messages
        7. 9.4.2.7 Allocation of Client Characteristic Configuration Table
      3. 9.4.3 Porting BLEv1.3.2 Projects to BLEv1.4.0
      4. 9.4.4 Porting BLEv1.2 Projects to BLEv1.3
      5. 9.4.5 Porting From CC2540 to CC2541 Project
    5. 9.5 Release Notes History
    6. 9.6 Document History
  11.   A GAP API
    1.     A.1 Commands
    2.     A.2 Configurable Parameters
    3.     A.3 Events
  12.   B GAPRole Peripheral Role API
    1.     B.1 Commands
    2.     B.2 Configurable Parameters
    3.     B.3 Callbacks
      1.      B.3.1 State Change Callback (pfnStateChange)
      2.      B.3.2 RSSI Callback (pfnRssiRead)
  13.   C GAPRole Central Role API
    1.     C.1 Commands
    2.     C.2 Configurable Parameters
    3.     C.3 Callbacks
      1.      C.3.1 RSSI Callback (rssiCB)
      2.      C.3.2 Central Event Callback (eventCB)
  14.   D GATT/ATT API
    1.     D.1 Overview
    2.     D.2 Server Commands
    3.     D.3 Client Commands
    4.     D.4 Return Values
    5.     D.5 Events
    6.     D.6 GATT Commands and Corresponding ATT Events
    7.     D.7 ATT_ERROR_RSP Error Codes
  15.   E GATTServApp API
    1.     E.1 Overview
    2.     E.2 Commands
  16.   F GAPBondMgr API
    1.     F.1 Overview
    2.     F.2 Commands
    3.     F.3 Configurable Parameters
    4.     F.4 Callbacks
      1.      F.4.1 Passcode Callback (passcodeCB)
      2.      F.4.2 Pairing State Callback (pairStateCB)
  17.   G HCI Extension API
    1.     G.1 Overview
    2.     G.2 Commands
    3.     G.3 Host Error Codes
  18.   Revision History

GATT Services and Profile

A GATT service is a collection of characteristics. For example, the heart rate service contains a heart rate measurement characteristic and a body location characteristic. You can group services together to form a profile. Many profiles implement only one service; so the two terms are used interchangeably.

The SimpleBLEPeripheral application has the following four GATT profiles:

  • Mandatory GAP Service – This service contains device and access information such as the device name, vendor identification, and product identification. This service is a part of the Bluetooth Low Energy protocol stack and is required for every Bluetooth Low Energy device per the Bluetooth Low Energy specification. The source code for this service is not provided but is built into the stack library.
  • Mandatory GATT Service – This service contains information about the GATT server and is a part of the Bluetooth Low Energy protocol stack. This service is required for every GATT server device per the Bluetooth Low Energy specification. The source code for this service is not provided but is built into the stack library.
  • Device Information Service – This service exposes information about the device such as the hardware version, software version, firmware version, regulatory information, compliance information, and the name of the manufacturer. The Device Information Service is part of the Bluetooth Low Energy protocol stack and is configured by the application. For more information, see Device Information Service (Bluetooth Specification), version 1.0 (24-May-2011).
  • simpleGATTProfile Service – This service is a sample profile for testing and demonstration. The full source code is in the files simpleGATTProfile.c and simpleGATTProfile.h.

Figure 5-9 shows and describes the portion of the attribute table in the SimpleBLEPeripheral project corresponding to the simpleGATTProfile service. This section is an introduction to the attribute table. For information on how this profile is implemented in the code, see Section 5.5.4.2.

figure_16_swru271.gifFigure 5-9 simpleGATTProfile Characteristic Table from BTool

The simpleGATTProfile contains the following five characteristics:

  • SIMPLEPROFILE_CHAR1 – A 1-byte value that can be read or written from a GATT-client device
  • SIMPLEPROFILE_CHAR2 – A 1-byte value that can be read from a GATT-client device, but cannot be written.
  • SIMPLEPROFILE_CHAR3 – A 1-byte value that can be written from a GATT-client device, but cannot be read.
  • SIMPLEPROFILE_CHAR4 – A 1-byte value that cannot be directly read or written from a GATT-client device (This value is notifiable and can be configured for notifications to be sent to a GATT client device.)
  • SIMPLEPROFILE_CHAR5 – A 5-byte value that can be read but not written from a GATT-client device

The following is a line-by-line description of this attribute table, referenced by the attribute handle:

  • 0x001F: This attribute is the simpleGATTprofile service declaration. This declaration has a UUID of 0x2800 (Bluetooth-defined GATT_PRIMARY_SERVICE_UUID). The value of this declaration is the UUID of the simpleGATTprofile (custom-defined by TI).
  • 0x0020: This attribute is the SIMPLEPROFILE_CHAR1 characteristic declaration. This declaration can be thought of as a pointer to the value of SIMPLEPROFILE_CHAR1. This declaration has a UUID of 0x2803 (Bluetooth-defined GATT_CHARACTER_UUID). The value of this declaration and all other characteristic declarations is a five-byte value explained as follows (from MSB to LSB):
    • Byte 0: the properties of the SIMPLEPROFILE_CHAR1. These properties are defined in the Bluetooth specification [13]. The following are a few of the relevant properties:
      • 0x02: Permits reads of the characteristic value
      • 0x04: Permits writes of the characteristic value without a response
      • 0x08: Permits writes of the characteristic value (with a response)
      • 0x10: Permits of notifications of the characteristic value (without acknowledgement)
      • 0x20: Permits notifications of the characteristic value (with acknowledgement)
    • The value of 0x0A means the characteristic is readable (0x02) and writeable (0x08).

    • Bytes 1-2: the byte-reversed handle where the SIMPLEPROFILE_CHAR1 value is located (handle 0x0021)
    • Bytes 3-4: the UUID of the SimpleProfileChar1 value (custom-defined 0xFFF1)
  • 0x0021: This attribute is the SIMPLEPROFILE_CHAR1 value. The attribute has a UUID of 0xFFF1 (custom-defined). Its value is the actual payload data of the characteristic. Indicated by its characteristic declaration (handle 0x0020), this value is readable and writeable.
  • 0x0022: This attribute is the SIMPLEPROFILE_CHAR1 user description. The attribute has a UUID of 0x2901 (Bluetooth-defined). Its value is a user-readable string describing the characteristic.
  • 0x0023 – 0x002F: These attributes follow the same structure as the SIMPLEPROFILE_CHAR1 with regard to the remaining four characteristics. The only different attribute, handle 0x002B, is described in the following bullet.
  • 0x002B: This attribute is the SIMPLEPROFILE_CHAR4 client characteristic configuration. This configuration has a UUID of 0x2902 (Bluetooth-defined). By writing to this attribute, a GATT server can configure the SIMPLEPROFILE_CHAR4 for notifications (writing 0x0001) or indications (writing 0x0002). Writing a 0x0000 to this attribute will disable notifications and indications.