GATT over BR/EDR

The purpose of this document is to give an overview of the GATT over BR/EDR. When the application needs to transmit Attribute Protocol PDU via BR/EDR transport, this functionality shall be added. The architecture is shown as follows:

../../../../../_images/gatt_over_bredr_architecture.png

GATT over BR/EDR Architecture

The application uses BR/EDR and LE manager module. The above figure shows the relationships between several modules in the application. More information about these modules can be found in the BR/EDR Host and LE Manager documentation.

Terminology and Concepts

This chapter introduces the concept of ATT bearer as described in the Bluetooth Core Specification.

An ATT bearer is a channel used to send Attribute Protocol PDUs. Each ATT bearer uses an L2CAP channel, which shall be either a dynamically allocated channel or the LE Attribute Protocol fixed channel. The L2CAP channel mode determines the behavior of Attribute Protocol on that ATT bearer. If the L2CAP channel mode is using Enhanced Credit Based Flow Control mode or (on BR/EDR) Enhanced Retransmission mode, the ATT bearer is known as an Enhanced ATT bearer. Any ATT bearer that is not an Enhanced ATT bearer, using any other L2CAP channel mode, is known as an unenhanced ATT bearer.

When using an unenhanced ATT bearer, L2CAP connection-oriented channels over BR/EDR not in Enhanced Flow Control mode can be used to transmit Attribute Protocol PDUs. All Attribute Protocol messages sent by GATT over an L2CAP channel are sent using a dynamic channel ID derived by connecting using a fixed Protocol Service Multiplex.

Feature Set

The provided functions are as below:

  • Establish and terminate an unenhanced ATT bearer over BR/EDR.

  • Definition of SDP record.

  • Implementation of profiles supporting GATT over BR/EDR.

Provided APIs

The table below shows a simple description of GATT over BR/EDR API. Related APIs are provided in the sdk\inc\framework\bt\bt_att.h, sdk\inc\ble_mgr\bt_gatt_client.h, and sdk\inc\ble_mgr\bt_gatt_svc.h.

APIs of GATT over BR/EDR

Header File

Description

API Reference

bt_att.h

Establish and terminate ATT bearer.

Bluetooth ATT Profile

bt_gatt_client.h

The Attribute Protocol client role implementation interface.

Bluetooth GATT Client

bt_gatt_svc.h

The Attribute Protocol server role implementation interface.

Bluetooth GATT Service

Initialization and Configurations

Configurations

Developers shall configure the following items through MCUConfig Tool:

Configure of GATT over BR/EDR

Configurable Item

Value

LE ATT over BR/EDR

Enable

LE CCCD Not Check

Enable

LE GATT ACL Number

>= (LE Link Number + att_over_bredr_num)

LE GATT Channel Number

>= (LE GATT ACL Number + att_over_bredr_num)

The above att_over_bredr_num represents the number of links supporting GATT over BR/EDR.

Initialization Process

The architecture is currently as follows:

../../../../../_images/gatt.png

GATT over BR/EDR Struct

To use GATT over BR/EDR, the initialization process is as follows:

  1. The ATT bearer over BR/EDR management module is used to establish and terminate the ATT bearer. bt_att_init() is used to initialize this module.

  2. Application also needs to register different ATT SDP, including the service UUID supported in GATT over BR/EDR.

    static const uint8_t att_sdp_record[] =
    {
        SDP_DATA_ELEM_SEQ_HDR,
        0x2b,
        // attribute SDP_ATTR_SRV_CLASS_ID_LIST
        SDP_UNSIGNED_TWO_BYTE,
        (uint8_t)(SDP_ATTR_SRV_CLASS_ID_LIST >> 8),
        (uint8_t)SDP_ATTR_SRV_CLASS_ID_LIST,
        SDP_DATA_ELEM_SEQ_HDR,
        0x03,
        SDP_UUID16_HDR,
        (uint8_t)(0xFEE7 >> 8),
        (uint8_t)(0xFEE7),
        // attribute SDP_ATTR_PROTO_DESC_LIST
        SDP_UNSIGNED_TWO_BYTE,
        (uint8_t)(SDP_ATTR_PROTO_DESC_LIST >> 8),
        (uint8_t)SDP_ATTR_PROTO_DESC_LIST,
        SDP_DATA_ELEM_SEQ_HDR,
        0x13,
        SDP_DATA_ELEM_SEQ_HDR,
        0x06,
        SDP_UUID16_HDR,
        (uint8_t)(UUID_L2CAP >> 8),
        (uint8_t)(UUID_L2CAP),
        SDP_UNSIGNED_TWO_BYTE,
        (uint8_t)(PSM_ATT >> 8),
        (uint8_t)(PSM_ATT),
        SDP_DATA_ELEM_SEQ_HDR,
        0x09,
        SDP_UUID16_HDR,
        (uint8_t)(UUID_ATT >> 8),
        (uint8_t)(UUID_ATT),
        SDP_UNSIGNED_TWO_BYTE,
        0x00,
        0x18,
        SDP_UNSIGNED_TWO_BYTE,
        0x00,
        0x20,
        // attribute SDP_ATTR_BROWSE_GROUP_LIST
        SDP_UNSIGNED_TWO_BYTE,
        (uint8_t)(SDP_ATTR_BROWSE_GROUP_LIST >> 8),
        (uint8_t)SDP_ATTR_BROWSE_GROUP_LIST,
        SDP_DATA_ELEM_SEQ_HDR,
        0x03,
        SDP_UUID16_HDR,
        (uint8_t)(UUID_PUBLIC_BROWSE_GROUP >> 8),
        (uint8_t)(UUID_PUBLIC_BROWSE_GROUP),
    };
    
    void app_sdp_init(void)
    {
        ......
        bt_sdp_record_add((void *)att_sdp_record);
    
    }
    
  3. GATT Services Register

    If the application needs to implement a server role based on the Attribute Protocol, users need to implement services based on bt_gatt_svc.h. Users need to register these services during initialization. The service to be implemented needs to support BR/EDR transport and requires setting the flag ATTRIB_FLAG_BREDR.

    const T_ATTRIB_APPL airsync_ble_service_tbl[] =
    {
        /* <<Primary Service>>, 0.. */
        {
            (ATTRIB_FLAG_VALUE_INCL | ATTRIB_FLAG_LE | ATTRIB_FLAG_BREDR),  /* wFlags     */
            {   /* bTypeValue */
                LO_WORD(GATT_UUID_PRIMARY_SERVICE),
                HI_WORD(GATT_UUID_PRIMARY_SERVICE),
                LO_WORD(GATT_UUID_AIRSYNC_SERVICE),      /* service UUID */
                HI_WORD(GATT_UUID_AIRSYNC_SERVICE)
            },
            UUID_16BIT_SIZE,                            /* bValueLen     */
            NULL,                                       /* pValueContext */
            GATT_PERM_READ                              /* wPermissions  */
        },
        ......
    };
    
  4. GATT Clients Register

    If the application needs to implement a client role based on the Attribute Protocol, users need to implement clients based on bt_gatt_client.h. Users need to register these clients during initialization.

Functions

ATT Bearer over BR/EDR Management Module

Initialize unenhanced ATT bearer over BR/EDR management module.
Establish an unenhanced ATT bearer over BR/EDR.
Terminate an unenhanced ATT bearer over BR/EDR.

Attribute Protocol Server Role Implementation

The steps to add are as follows:

  1. bt_gatt_svc.h is a feature provided by the ble mgr lib, so the project needs to include ble_mgr.lib.

  2. The application needs to handle the functions ble_mgr_handle_gap_msg() and ble_mgr_handle_gap_common_cb() from the ble mgr lib.

  3. All service registrations need to occur after the function gatt_svc_init() is initialized. The parameter mode of gatt_svc_init() needs to be set to GATT_SVC_USE_EXT_SERVER.

    void profile_init(void)
    {
        gatt_svc_init(GATT_SVC_USE_EXT_SERVER, MAX_BLE_SRV_NUM);
        bas_id = bas_reg_srv(app_bas_service_callback);
    }