Important: Before you run this example, make sure to program the SoftDevice.
This example application demonstrates a simple application that uses LE Secure Connections (LESC) to enforce GAP Security Mode 1 Level 4, which requires pairing or bonding using LESC with man-in-the-middle (MITM) protection. The application uses the Peer Manager module, which supports LESC in both roles.
The application can act both as a peripheral or as a central depending on how the connection is set up. It will both advertise and scan when started up and after disconnection, and whichever role is established first will be selected for the next connection.
If you want the application to act as a peripheral, simply connect to it from a smart device or from another board running the same application. If you want the application to act as a central, simply provide a peripheral advertising with the Heart Rate Service UUID in its advertising data (this again can be either a smart device or another board running the same application).
The application includes the Heart Rate Service both as a server and as a client:
Security for the Client Characteristic Configuration Descriptor (CCCD) in the Heart Rate Measurement characteristic is set at Security Mode 1 Level 4, which requires LESC with MITM. This means that whenever the collector tries to enable notifications it will need first to secure it using those parameters.
Since the SoftDevice does not include the functionality required to calculate Elliptic Curve Cryptography (ECC) public keys and shared secrets, an external library is required for this purpose. Bindings and build files are provided for a well known open source library, micro-ecc, although the library itself is not provided.
Important note: micro-ecc is an open source library. Its usage requires compliance with the license of the library as stated on the LICENSE.txt file included in micro-ecc. It is the developer's responsibility to ensure compliance with all the terms present.
To use micro-ecc with this project you will need to do the following:
InstallFolder\external\micro-ecc\micro-ecc
. The revision tested at the time of the release of this SDK version is b6c0cdbe7d20af48b0c2a909a66ff00b093d1542
.InstallFolder\external\micro-ecc\nrf51_keil\armgcc
InstallFolder\external\micro-ecc\nrf52_keil\armgcc
InstallFolder\external\micro-ecc\nrf51_iar\armgcc
InstallFolder\external\micro-ecc\nrf52_iar\armgcc
InstallFolder\external\micro-ecc\nrf51_armgcc\armgcc
InstallFolder\external\micro-ecc\nrf52_armgcc\armgcc
make
to compile the library.InstallFolder\examples\ble_central_and_peripheral\experimental\ble_app_multirole_lesc\Board\Toolchain
Note: If you want to compile the micro-ecc library yourself using your own Makefile or other means, please make sure you use the same compilation options found in the Makefiles. This is specially important for preprocessor macros, and in particular uECC_VLI_NATIVE_LITTLE_ENDIAN=1
, which needs to be set for the library to work properly with the example.
You can find the source code and project file of the example in the following folder: <InstallFolder>\examples\ble_central_and_peripheral\experimental\ble_app_multirole_lesc
LED assignments:
The application uses the following UART settings:
Testing the application requires one of the following configurations:
Test the BLE LESC Multirole Example application by performing the following steps:
lv4
set to 1.