3.17 Bluetooth® Low Energy HID over GATT Profile Service

The HID over GATT profile defines the procedures and features to be used by BLE HID devices using GATT and Bluetooth HID Hosts using GATT. This profile is an adaptation of the USB HID specification to operate over a BLE wireless link.

The HID Over GATT Profile (HOGP) is a Bluetooth SIG (Special Interest Group) standard that defines how HID information is exposed and exchanged over the Generic Attribute (GATT) protocol in BLE. HOGP extends the capabilities of BLE devices to support HID functionality.

HOGP is built on top of the BLE protocol stack and uses GATT for communication. It leverages the GATT Server-Client architecture to enable HID devices to send and receive HID reports.

Recommended Reading

  1. BLE Software Specification
  2. Getting Started with WME Bluetooth Low Energy Applications
Note: Refer to the Getting Started with WME Bluetooth Low Energy Applications from Related Links

Hardware Required

Table 3-42.  Hardware Required
ToolQty
Curiosity Board1
Micro USB cable1

Extreme Deep Sleep Current Measurement

Current measured in Extreme Deep Sleep mode as per “Wireless_ble v 1.1.0” and “Wireless_pic32cxbz_wbz v1.2.0” in A2 version of the WBZ451 Module is around 131 nA.

Figure 3-218. Extreme Deep Sleep Mode Current Measurement

Software Requirement

  • MPLAB X IPE: For programming the precompiled hex file.
  • MPLAB X IDE: For programming the application example.
  • Teraterm: Terminal Emulator for displaying UART output.

Programming the Precompiled Hex File or Application Example

Programming the .hex File using MPLAB X IPE

  1. Precompiled .hex file is located in “<Harmony Content Path>wireless_apps_ble\apps\ble_hogps_app\hex\” folder.
  2. For more information on the programming steps, refer to the Programming a Device in MPLAB IPE.
    Note: Users must choose the correct device and tool information.

Programming the Application using MPLAB X IDE:

  1. Follow the steps mentioned in Running a Precompiled Example
  2. Open and program the application example “ble_hogps_app_xxxx.X” where xxxx refer to device (for example: WBZ451, project file: ble_hogps_app_wbz451.X) located in “<Harmony Content Path>\wireless_apps_ble\apps\ble_hogps_app\firmware” using MPLAB X IDE .

For more details on finding the Harmony content path, refer to Installing the MCC Plugin.

Role Descriptions

GATT Server Role

In the context of HOGP, the GATT Server role is typically assumed by the HID device. The GATT Server exposes HID services and characteristics, making the device accessible to GATT Clients. It supports
  • One or more instances of HID Service
  • One or more instances of battery services
  • Single instance of device information service
  • Optionally, one instance of Scan server role of Scan parameter profile.
GATT Client Role

GATT Clients, such as smart phones or computers, interact with HID devices by discovering and accessing HID services and characteristics. They initiate actions based on user input or requirements. It supports Scan Client role of the Scan parameter profile.

Pairing and Security

Security is crucial when dealing with HID devices, especially in scenarios where sensitive data may be transmitted.

The HID Host shall bond with the HID Device. The HID Host shall support LE Security Mode 1 and Security Level 2 and optionally Security Level 3.

Demo Description

  • Refer HOGPS Demo Description.
    Note: The BLE connection status will be indicated by the green color of the RGB LED.

Developing the Application from scratch using MCC

This section explains the steps required by a user to develop this application example from scratch using MCC.
Note: It is recommended that new users of MCC to go through the MPLAB® Code Configurator (MCC) User's Guide.
  1. Create a new MCC Harmony Project by selecting the device. For more details, refer to Creating a New MCC Harmony Project.
  2. Launch the MCC from the toolbar as illustrated below. The project graph will open with the default components.
    Figure 3-219. MCC
  3. In the Device Resources window, expand Libraries > Harmony > Wireless > Application Services. Then, click the Plus Symbol to add the HID Over GATT App Service Component to the project graph.
    Figure 3-220. HID Over GATT App Service
  4. All BLE HOGPS related components will be added into the project graph. Accept dependencies or satisfiers by selecting Yes
  5. To enable digital and communication interfaces, refer to Enabling Digital Input/Output and Communication Interfaces Through System Hardware Definition (SHD) component in Getting Started with WME Bluetooth Low Energy Applications from Related Links.
  6. For more details, refer to the link Configuring FreeRTOS in Getting Started with WME Bluetooth Low Energy Applications from Related Links.
  7. For WBZ451
    1. Change WBZ451-CURIOSITY Component setting as illustrated in the following figure
      Figure 3-221. WBZ451-CURIOSITY Configuration
    2. Change FreeRTOS Component setting as illustrated in the following figure
      Figure 3-222. FreeRTOS Configuration
    3. Change Device_Support Component setting as illustrated in the following figure
      Figure 3-223. Device_Support Configuration
    4. Add TRNG Component from Device Resource>Libraries>Harmony>Peripherals>TRNG.
      Figure 3-224. TRNG Component
    5. Verify if the project graph window has all the expected components, as illustrated in the following figure:
      Figure 3-225. Project Graph
  8. For WBZ351
    1. Change WBZ351-CURIOSITY Component setting as illustrated in the following figure
      Figure 3-226. WBZ351-CURIOSITY Configuration
    2. Verify if the project graph window has all the expected components, as illustrated in the following figure:
      Figure 3-227. Project Graph
  9. Select the HID Over GATT App Service component. In the Configuration Options, the Enable Server Role option will be enabled by default. If it is not enabled, please enable this option. Additionally, ensure that the Enable app code generation option is also enabled.

    Figure 3-228. HID Over GATT App Service Component
    Figure 3-229. HID Over GATT App Service Configuration
  10. Enabling the Server role option in Apple Notification App Service component will configure BLE Stack component . Additionally, selecting the Enable App Code Generation option will generate the necessary application files related to the service during the code generation process. Verify the BLE Stack configuration as illustrated below.
    Figure 3-230. BLE Stack Configuration
    Figure 3-231. BLE Stack Configuration

Files Containing User Application Code

Source code for the application will be generated from the MCC interface by clicking Generate Code. User can add or edit the code in the highlighted files shown below.
Figure 3-232. Files
Details on files that user can modify
Table 3-43. Source Files
Source FilesUsage
app.cApplication State machine, includes calls for Initialization of all BLE stack (GAP,GATT, SMP, L2CAP) related component configurations
app_ble_callbacks.cAll the event functions related to GAP, GATT, SMP and L2CAP events that user can use or modify .
app_hogps_callbacks.cAll the event functions related to HOGPS event handles that user can use or modify.
app_utility.cContains generic utility functions that serve the purpose of providing reusable, common functionalities that can be applied across various parts of a program.
Note: app.c is auto generated and has a state machine based application code sample. Users can use this template to develop their application. Main application logic is implemented in void APP_Tasks() function.
Figure 3-233. app.c
Figure 3-234. app.c

References

  • Bluetooth Low Energy HOGPS Application for: WBZ451
  • Bluetooth Low Energy HOGPS Application for: WBZ351