nRF51 SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
HID Keyboard Application

Modules

 main.c
 HID Keyboard Sample Application main file.
 

Detailed Description

The HID Keyboard Application is a firmware example that implements the HID over GATT profile for keyboard using the hardware delivered in the nRF51822 Development Kit.

The source code and project file can be found in the <InstallFolder>\Nordic\nrf51822\Board\nrf6310\ble\ble_app_hids_keyboard folder.

The application includes the three mandatory services needed for the HID over GATT profile:

Note
This application is not power optimised!
The application will stop advertising and go to system-off mode after
  • 3 minutes and 30 seconds, if no advertising with whitelist was done OR
  • 4 minutes, if advertising with whitelist was done.

    Push the button 0 to restart advertising.

Setup

Instructions on how to set up the nRFgo Motherboard: nRFgo Motherboard Setup (nRF6310).

The following are the list of buttons and LEDs used by this application.

LED assignments:

Buttons assignments when in system-off:

Buttons assignments when connected:

Testing

The HID Keyboard Application is intended to be tested using a Windows 8 PC with a Bluetooth radio:

  1. Compile and program the application. Observe that the Advertising LED is lit.
  2. On the Windows 8 PC, search for Bluetooth devices, and connect to the device named 'Nordic_Keyboard'. Observe that the Connected LED is lit, and the Advertising LED is off.
  3. Open a text editing application (e.g. Notepad).
  4. Press Button 0 on the board. This will send one character of the test message 'hello' (the test message includes carriage return) to the PC on, and this will be displayed in the text editor.
  5. Turn Caps-Lock On on the PC. Observe that:
    • LED2 is lit.
    • The text 'CAPSON' will be seen on the text editor window on the PC. This verifies that output report characteristic has been written successfully on the HID device.
  6. Turn Caps-Lock Off on the PC. This should result in two events:
    • LED2 is off.
    • The text 'capsof' will be seen on the editor window.
  7. Disconnect the PC from the device by removing the device from the PC's devices list. Observe that the advertising LED is lit and, for the first period the Directed advertising LED is lit also, the that it switches to Whitelist LED, then to only advertising LED, then to advertising and Slow advertising mode LEDs and then all off.

The HID Keyboard Application can also be tested using the Master Control Panel as follows:

  1. Compile and program the application. Observe that the Advertising LED is lit.
  2. Connect to the device from Master Control Panel (the device will be advertising as 'Nordic_Keyboard'), then bond and perform service discovery. Observe that the Connected LED is lit, and the Advertising LED is off.
  3. Click the 'Enable services' button on Master Control Panel, and observe that Battery Level notifications are being received every two seconds.
  4. Push Button 0 on the nRFgo board. Observe that 2 notifications on one of the HID Report characteristics are received; two notifications (press and release) each for one character of the test message. The first one has the value '00000B0000000000', the second has the value '0000000000000000'. This corresponds to press and release of character 'h'. Similarly, press and release events subsequently will result in press and release notifications of subsequent characters of the the test string. Therefore, pushing Button 0 again will result in notification of press and release reports for character 'e'.
  5. Simulate Caps-lock ON:
    • On the Master Control Panel, select the HID Report which has the properties Read, WriteWithoutResponse and Write (i.e. the Output Report) and UUID: 0x2A4D.
    • Click the 'hex' radio button.
    • Enter '02' in the text box.
    • Click the 'Send update' button.
    • Observe that LED 2 is lit and that 7 notifications on the other HID Report characteristic (i.e. the Input Report) are received. The first one has the value '0000060413161211', the second has the value '0000000413161211', third has the value '0000000013161211', and so on until release event for all characters is sent as the 7th one as '0000000000000000'.
  6. Simulate Caps-lock OFF:
    • On the Master Control Panel, select the HID Report which has the properties Read, WriteWithoutResponse and Write (i.e. the Output Report).
    • Click the 'hex' radio button.
    • Enter '00' in the text box.
    • Click the 'Send update' button.
    • Observe that LED 2 is off, and that two notifications on the other HID Report characteristic are received. The first one has the value '0000060413161209', the second has the value '0000000413161209', third has the value '0000000013161209', and so on until release event for all characters is sent as the 7th one as '0000000000000000'.