The Bluetooth Low Energy (BLE) middleware contains a comprehensive API to configure the BLE Stack and the underlying chip hardware.
The standalone BT Configurator is shipped in ModusToolbox to make it easy to configure PSoC 6 BLE Middleware.
Include cy_ble_common.h and cy_ble_event_handler.h to get access to all functions and other declarations in this library. If you are using the ModusToolbox BT Configurator, you can include cycfg_ble.h only.
The PSoC 6 BLE Middleware incorporates a Bluetooth Core Specification v5.0 compliant protocol stack. You may access the GAP, GATT and L2CAP layers of the stack using the API.
The API are broadly categorized as follows:
Features:
BLE is used in very low-power network and Internet of Things (IoT) solutions using low-cost battery operated devices that can quickly connect and form simple wireless links. Target applications include HID, remote controls, sports and fitness monitors, portable medical devices and smart phone accessories, among many others.
The BLE resource supports numerous SIG-adopted GATT-based Profiles and Services. Each of these can be configured for either a GATT Client or GATT Server. It generates all the necessary code for a particular Profile/Service operation, as configured in the BLE Configurator.
You can create custom Profiles that use existing Services, and you can create custom Services with custom Characteristics and Descriptors.
For testing and debugging, the PSoC 6 BLE Middleware can be configured to use Host Controller Interface (HCI) mode through a UART. Refer to Initialize and Enable PSoC 6 BLE Middleware in Controller-only Mode (HCI over Software API).
For over-the-air verification, the Cypress CySmart Central Emulation Tool can be used for generic Bluetooth host stack emulation.
PSoC 6 BLE Middleware consists of the BLE Stack, BLE Profile, Hardware Abstraction Layer (HAL), and the Link Layer. The following figure shows the high-level architecture of the PSoC 6 BLE Middleware, illustrating the relationship between each of the layers and how the application interacts with the PSoC 6 BLE Middleware. Note that the application uses callback functions to handle BLE events, which you can use to build your state machine.
The following block diagram shows the architecture of PSoC 6 BLE Middleware under Complete BLE Protocol mode.
The following block diagram shows the architecture of PSoC 6 BLE Middleware under Controller Only mode (HCI over Software API).
The following sub-sections give an overview of each of these layers.
The BLE stack implements the core BLE functionality as defined in Bluetooth Core Specification 5.0. The stack is included as a pre-compiled library in the PSoC 6 BLE Middleware library. The BLE Stack implements the layered architecture of the BLE protocol stack as shown in the following figure.
The Generic Access Profile defines the procedures related to discovery of Bluetooth devices and the link- management aspects of connecting to Bluetooth devices. In addition, this profile includes common format requirements for parameters accessible on the user interface level.
The Generic Access Profile defines the following roles when operating over the LE physical channel:
The Generic Attribute Profile defines a generic service framework using the ATT protocol layer. This framework defines the procedures and formats of services and their characteristics. It defines the procedures for Service, Characteristic, and Descriptor discovery, reading, writing, notifying, and indicating Characteristics, as well as configuring the broadcast of Characteristics. GATT roles are:
The Attribute Protocol layer defines a Client/Server architecture above the BLE logical transport channel. The attribute protocol allows a device referred to as the GATT Server to expose a set of attributes and their associated values to a peer device referred to as the GATT Client. Attributes exposed by the GATT Server can be discovered, read, and written by a GATT Client, and can be indicated and notified by the GATT Server. All the transactions on attributes are atomic.
The Security Manager Protocol defines the procedures and behavior to manage pairing, authentication, and encryption between the devices. These include:
L2CAP provides a connectionless data channel. LE L2CAP provides the following features:
The HCI layer implements a command, event, and data interface to allow link layer access from upper layers such as GAP, L2CAP, and SMP.
The Link Layer implements a command, event, and data interface to allow link layer access from upper layers such as GAP, L2CAP, and SMP. The LL protocol manages the physical BLE connections between devices. It supports all LL states such as Advertising, Scanning, Initiating, and Connecting (Master and Slave). It implements all the key link control procedures such as LE Encryption, LE Connection Update, LE Channel Update, and LE Ping.
The Link Layer is a hardware-firmware co-implementation, where the key time critical LL functions are implemented in the LL hardware. The LL firmware maintains and controls the key LL procedure state machines. It supports all the BLE chip-specific low-power modes. The BLE Stack is a pre-compiled library. The appropriate configuration of the BLE Stack library is linked during a build process based on the application. The BLE Stack libraries are Arm Embedded Application Binary Interface (EABI) compliant and are compiled using Arm compiler version 5.03.
In BLE, data is organized into concepts called Profiles, Services, and Characteristics.
The Heart Rate Profile contains a Heart Rate Service and a Device Information Service. Within the Heart Rate Service, there are three Characteristics, each containing different information. The device in the diagram is configured in the Sensor role, meaning that in the context of the Heart Rate Profile, the device is a GAP Peripheral and a GATT Server. These concepts are explained in the BLE Stack description.
The Profile layer is provided by PSoC 6 BLE Middleware using the parameter configurations specified in the Bluetooth Configurator. The Profile implements the Profile-specific attribute database and functions required for the application. You can choose to configure the standard SIG adopted Profile and generate a design, or define a Custom Profile required by an application.
The HAL implements the interface between the BLE stack and the underlying hardware. This layer is meant for the stack only and it is not advisable to modify it.