A typical application code implements three operating modes: initialization, normal operation, and low-power operation. Initialization should happen only at system power-up, or when waking from system hibernation. After initialization, the PSoC 6 BLE Middleware enters normal operation and periodically enters various degrees of low-power operation to conserve power.
BLESS Power Modes | MCU Power Modes | ||||
---|---|---|---|---|---|
Active | Sleep | Deep sleep | Hibernate | ||
Active (idle/Tx/Rx) | Y | Y | |||
Deep sleep (ECO off) | Y | Y | Y | ||
Off | Y |
To better understand of BLE operation flow refer Quick Start Guide section based on simple BLE example project.
The PSoC 6 BLE Middleware stores the link key of a connection after pairing with the remote device. If a connection is lost and re-established, the devices use the previously stored key for the connection. The BLE stack updates the bonding data in RAM while the devices are connected. If the bonding data is to be retained during shutdown, the application can use Cy_BLE_StoreBondingData() API to write the bonding data from RAM to the dedicated flash location, as defined by the PSoC 6 BLE Middleware.
Refer to the CE215121_BLE_HID_Keyboard code example for usage details.
The LFCLK configuration affects the PSoC 6 BLE Middleware's ability to operate in BLESS deep sleep mode. If the WCO or PILO are chosen as source clock, then the PSoC 6 BLE Middleware BLESS deep sleep mode is available for use. However, if the ILO is chosen, then the PSoC 6 BLE Middleware cannot enter BLESS deep sleep.
The PSoC 6 BLE Middleware supports using the Precision ILO (PILO) (instead of the WCO) as the LF clock source.
Using the PILO has limitations:
Using the PILO as the LF clock source requires:
Both actions must happen during every power-up to get closest to the target frequency.
The following code snippet shows usage:
The PSoC 6 BLE Middleware supports up to four simultaneous Multi-Master Multi-Slave (MMMS) BLE connections in any combination of roles. For example, it can be a master of four slave devices (4M), a master of three slave devices and a slave of another device (3M1S), or a slave of four devices (4S), or any other combination. To configure the maximum number of BLE connections, refer to the General Tab section of ModusToolbox Bluetooth Configurator Guide (Maximum number of BLE connections). The PSoC 6 BLE Middleware supports a single instance of a GATT Server (single GATT database). The number of the Server instance field is always fixed to 1 in the Bluetooth Configurator dialog. You can add additional Services or a complete Server Profile to the existing Server tree and build a GATT database. This single GATT database is reused across all BLE connections. The PSoC 6 BLE Middleware manages multiple Client Characteristic Configuration Descriptor (CCCD) values. The CCCD value for each active connection is unique.
The maximum number of CCCD storage SRAM data structures supported by the PSoC 6 BLE Middleware is determined by the number of active BLE connections/links that you select. The PSoC 6 BLE Middleware restores CCCD values in flash for each of the bonded devices while establishing a connection with a peer device.
Use the connection handle at the application level to manage the multi-connection. The connection handle (cy_stc_ble_conn_handle_t) appears when the connection is established (as the event parameter of the CY_BLE_EVT_GATT_CONNECT_IND event).
To work with a particular connection, BLE APIs (BLE Stack APIs, BLE Profile APIs) provide the parameter connHandle (e.g., Cy_BLE_BASS_SendNotification(cy_stc_ble_conn_handle_t connHandle,... ).) BLE events from the AppCallback function include a connHandle in eventParam structures to distinguish to which connection this event relates. The following code shows how an application can manage connection handles:
Loop through all connected devices:
Use the Cy_BLE_GetDeviceRole(cy_stc_ble_conn_handle_t *connHandle) function to discover the role of the link-layer device connected to a peer device with the connection handle indicated by the connHandle parameter. Write attributes (characteristic, descriptors) requests from the peer device(s) for adopted services (e.g. BAS, HIDS, HRS, etc) handled by the PSoC 6 BLE Middleware.
For the Custom service, write attributes requests handled by the application level in the AppCallback () callback event function. The following code shows the handling of the Write operation by a peer device for the Custom service:
The common MMMS usage are Multi-Master Single-Slave and Multi-Role when the PSoC 6 BLE Middleware is configured in all the GAP roles (Central, Peripheral, Observer, and Broadcaster).
Multi-Master Single-Slave Usage Block Diagram
Multi-Role Usage Block Diagram
Refer to code examples CE215118_BLE_Multi_Master_Single_Slave and CE215555_BLE_Multi_Role for more details.
The PSoC 6 BLE Middleware exposes BLE interrupt notifications to the application which indicates a different link layer and radio state transitions to the user from the BLESS interrupt context. The user registers for a particular type of a callback and the PSoC 6 BLE Middleware will call that registered callback basing on the registered mask (Refer to the Cy_BLE_RegisterInterruptCallback() and Cy_BLE_UnRegisterInterruptCallback() APIs). All interrupts masks are specified in the cy_en_ble_interrupt_callback_feature_t enumeration.
The possible interrupts which can trigger a user callback:
An application can use these interrupt callbacks to know when the RF activity is about to begin/end or when the BLE device changes its state from advertisement to connected, or when the BLESS transitions between active and low-power modes, etc. These BLESS real-time states can be used to synchronize an application with the BLESS or prevent radio interference with other peripherals etc.
To register / un-register a callback following APIs are available: Cy_BLE_RegisterInterruptCallback() and Cy_BLE_UnRegisterInterruptCallback().
The PSoC 6 BLE Middleware stack does not support the following optional Bluetooth v5.0 protocol features, as listed in Vol 6, Part B, section 4.6 of the specification:
The PSoC 6 BLE Middleware automatically registers sleep and deep sleep callback functions. These functions request the BLE Stack to put Bluetooth Low Energy Sub-System (BLESS) to low-power mode.
RF front ends come in a variety of combinations. The most popular and comprehensive RF front ends come with a built-in power amplifier (PA) in the transmit path, a low-noise amplifier (LNA) in the receive path, a transmit/receive bypass path to bypass both the PA and LNA, and RF switches to select between transmit, receive, and bypass paths. Some front ends support multiple antennas. Some front ends have a built-in low-pass filter after the power amplifier. The discrete front ends also have almost the same configuration.
The polarity of these signals are configurable and can be set in the EXT_PA_LNA_CTRL register by Cy_BLE_ConfigureExtPA() API.
For more information, refer to the following documents:
ModusToolbox Software Environment, Quick Start Guide, Documentation, and Videos
PSoC 6 BLE Middleware Code Examples at GITHUB
ModusToolbox BT Configurator Tool Guide
ModusToolbox Device Configurator Tool Guide
PSoC 6 BLE Middleware API Reference Guide
AN210781 - Getting Started with PSoC 6 MCU with Bluetooth Low, Energy, (BLE) Connectivity
PDL API Reference
PSoC 6 Technical Reference Manual
CySmart - BLE Test and Debug Tool
CY8CKIT-062-BLE PSoC 6 BLE Pioneer Kit
Cypress Semiconductor