nRF5 SDK v15.3.0
Experimental: HID Keyboard Application with BLE pairing using NFC
This example requires one of the following SoftDevices: S132, S140

Important: Before you run this example, make sure to program the SoftDevice.

This example is based on the BLE Peripheral HID Keyboard Application example. It implements the HID over GATT profile for keyboard and enables pairing from a BLE Central device using the NFC interface. To do the pairing, it uses the NFC tag module that is one of the nRF52 peripherals and the NFC antenna that is delivered with the nRF52 Development Kit.

The application shows the usage of the BLE pairing message generation module. It includes the same services that are present in the original HID Keyboard Application example. See the documentation for that example for details. The following description presents only the differences from the original example.

When the application starts, it initializes and starts the NFCT peripheral, which is used for pairing. The application does not start advertising immediately, but only when the NFC tag is read by an NFC polling device, for example a smartphone or a tablet with NFC support. The message that the tag sends to the NFC device contains data required to initiate pairing. To start the NFC data transfer, the NFC device must touch the NFC antenna that is connected to the nRF52 Development Kit.

After reading the tag, the device can pair with the nRF52 device which is advertising. After connecting, the example application behaves the same way as the original HID Keyboard example. Reading the NFC tag again when the application is in a connected state causes disconnection and restarts advertising. When the connection is lost due to other reasons, advertising does not restart automatically. To restart advertising, the NFC tag must be read again. Then advertising with whitelist starts, so only the paired peer can connect. To pair with a different device, remove bonding information by pressing Button 2 on application startup.

Only one NFC transfer is required to connect to the nRF52 device and get the HID services using the HID keyboard application for Android or Windows Phone. For this, the application uses a Handover Select NDEF message (see BLE pairing message generation). However, you can easily modify the application to use only one LE OOB NDEF message (and support only Android) or only one EP OOB NDEF message (and support only Windows Phone). Also, you can configure the application to use Out-Of-Band pairing instead of Just Works pairing.

This example demonstrates the use of Low Energy Secure Connections (LESC). The default cryptographic backend used for LESC is CC310 (when run on nRF52840) or Oberon (for other SoCs). To use micro-ecc instead, follow the steps in Enabling micro-ecc support in selected examples.

This application is not power optimized!
This application supports pairing with just one peer.


You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\ble_peripheral\experimental\ble_app_hids_keyboard_pairing_nfc

Button assignments - in addition to those defined in BSP BLE Button Assignments:

Button assignments - in addition to those defined in BSP BLE Button Assignments:


Test the HID Keyboard Application with BLE pairing using NFC with a smartphone or tablet (with Android or Windows Phone, Android is recommended) that supports NFC by performing the following steps:

  1. Compile and program the application.
  2. Touch the NFC antenna with the smartphone or tablet and observe that the BSP_INDICATE_ADVERTISING state is indicated.
  3. Confirm pairing with 'Nordic_Keyboard' in a pop-up window on the smartphone/tablet and observe that the BSP_INDICATE_CONNECTED state is indicated.
  4. Test the HID Keyboard Application by using it as input keyboard for the system (use Button 1 and Button 2).

Documentation feedback | Developer Zone | Subscribe | Updated