HID Emulated Keyboard

Table of Contents

Introduction

The hid_emu_kbd project implements a simple Bluetooth low energy peripheral device with GATT services and implements the Glucose Profile. This project can be a framework for developing many different glucose sensor applications.

This project uses a single stack and app configuration. It is summarized in the table below:

App Build Configuration Compatible Stack Configuration Description
FlashROM_StackLibrary FlashROM_Library Application build configuration linked to Stack library (fully executable)

FlashROM_Library configurations use the stack library configuration, which is explained here.

This document discusses the procedure for using the hid_emu_kbd application when the FlashROM_StackLibrary configurations are used. The project can also be modified to support other configurations similar to the simple_peripheral project.

Hardware Prerequisites

The default hid_emu_kbd configuration uses the LAUNCHXL-CC2640R2. This hardware configuration is shown in the below image:

For custom hardware, see the Running the SDK on Custom Boards section of the BLE5-Stack User’s Guide.

Software Prerequisites

For information on what versions of Code Composer Studio and IAR Embedded Workbench to use, see the Release Notes located in the docs/ble5stack folder. For information on how to import this project into your IDE workspace and build/run, please refer to The CC2640R2F Platform section in the BLE5-Stack User’s Guide.

Service/Profile Table

This project contains 3 services. The Human Interface Device (HID) service has 8 characteristics, the scan parameters has 2 characteristics, and the battery service has 1 characteristic.

The following table lists the characteristics of the HID service:

Usage

This application does not use any display interfaces. It does use the keys for input for sending key presses over the air. Note that a secure connection must be established before key presses is sent to the peer device. The following describes the buttons used in the project:

Key Description
BTN-1 Send LEFT Key HID keyboard report
BTN-2 Send RIGHT Key HID keyboard report

This document will use Android BLE Scanner as the phone app that will act as the HID Host that will connect to the hid_emu_kbd application which acts as the HID Device. BLE Scanner can be downloaded free of charge on the Play Store.

Once the hid_emu_kbd sample application starts, the device will start advertising.

Turn on Bluetooth on your Android device in Settings.

Then the phone should scan for devices, and HID Keyboard should be displayed under ‘Available devices’ (note that the navigation might be slightly different depending on your mobile application):

Press the “HID Keyboard” as shown in the figure above to pair and connect to the HID Device. Once connected, in the settings, the device should show up under ‘Paired devices’ and should say ‘Connected’:

Then open up an app with text editor and press the BTN-1 and BTN-2 on the CC2640R2 LaunchPad to move the cursor on the text.

Also note that if there is no HID activity for a period of time (60 seconds by default), the HID device will disconnect. When the connection is closed, the HID device advertises again if AUTO_ADV is set to TRUE in preprocessor defined symbols.

See the HID Service for more details on service specifications.