Bluetooth LE Connection Manager
The connection manager is a helper module that contains common application configurations and interactions with the Bluetooth LE Host Stack. It implements the following events and methods:
Host Stack GAP Generic Event
Host Stack Connection Event on both GAP Peripheral and GAP Central configuration
Host Stack configuration for GAP Peripheral or GAP Central
GAP generic event
The GAP Generic Event is triggered by the Bluetooth LE Host Stack and sent to the application via the generic callback. Before any application-specific interactions, the Connection Manager callback is called to handle common application events, such as device address storage.
**void** **BleApp\_GenericCallback** ( gapGenericEvent_t * pGenericEvent)
{
/* Call Bluetooth Low Energy Conn Manager */
BleConnManager_GenericEvent(pGenericEvent);
**switch** (pGenericEvent-> eventType )
{
...
}
}
In the BleConnManager_GenericEvent function, local keys are generated.
The local LTK, IRK, and CSRK as well as the EDIV and RAND are obtained hashing over the board’s UID and stored in RAM as plain-text every time the gInitializationComplete_c event is received.
In Advanced Secure mode, local IRK and CSRK are generated using the EdgeLock Secure Enclave and stored into a dedicated NVM data set as ELKE blobs (40 bytes blob encrypted using unique die key) on the first
gInitializationComplete_c
event received.
The NBU Decryption key for IRK is generated and distributed to the NBU over the private key bus. The EIRK blob (16 bytes blob which can be decrypted only by NBU hardware using NBU Decryption key for IRK) is generated from the IRK ELKE blob and stored in the RAM to be used for controller privacy on every gInitializationComplete_c
event received. For the host privacy, the ELKE IRK blob is used instead. For details, refer to the section “Advanced security capabilities”.
Parent topic:Bluetooth LE Connection Manager
GAP configuration
The GAP Central or Peripheral Configuration is used to create common configurations (such as setting the public address, registering the security requirements, adding the addresses of bonded devices in the Controller Filter Accept List), which can be customized by the application afterwards. It is called inside the BluetoothLEHost_Initialized callback function, before any application-specific configuration, as shown in the example code below.
**static** **void** **BluetoothLEHost\_Initialized**()
{
/* Set common GAP configuration */
BleConnManager_GapCommonConfig();
...
}
Parent topic:Bluetooth LE Connection Manager
GAP connection event
The GAP Connection Event is triggered by the Host Stack and sent to the application via the connection callback. Before any application-specific interactions, the Connection Manager callback is called to handle common application events, such as device connect, disconnect or pairing-related requests. It is called inside the registered connection such as shown below:
**static** **void** **BleApp\_ConnectionCallback** ( deviceId_t peerDeviceId, gapConnectionEvent_t * pConnectionEvent)
{
/* Connection Manager to handle Host Stack interactions */
BleConnManager_GapPeripheralEvent(peerDeviceId, pConnectionEvent);
**switch** (pConnectionEvent-> eventType )
{
...
}
}
It is strongly recommended that the application developer uses the app.c
module to add custom code.
Parent topic:Bluetooth LE Connection Manager
Privacy
To enable or disable Privacy, the following APIs may be used:
bleResult_t
**BleConnManager\_EnablePrivacy**(void);
bleResult_t
**BleConnManager\_DisablePrivacy**(void);
The function BleConnManager_EnablePrivacy calls BleConnManager_ManagePrivacyInternal after checking if the privacy is enabled.
static bleResult_t
**BleConnManager\_ManagePrivacyInternal**
(bool_t bCheckNewBond);
If the privacy feature is supported (gAppUsePrivacy_d = 1), the Connection Manager activates Controller Privacy or Host Privacy depending on the board capabilities.
The bCheckNewBond is a boolean that tells the Manager whether it should check or not if a bond between the devices already exists.
In order to update the identity information after a bond is added or removed privacy should be disabled and enabled. For pairing with bonding this is done automatically in ble_conn_manager. In case the application adds or removes a bond through the GAP API, it should also disable and enable privacy.
Parent topic:Bluetooth LE Connection Manager
Parent topic:Application Structure