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
- BLE Software Specification
- Getting Started with WME Bluetooth Low Energy Applications
Hardware Required
Tool | Qty |
---|---|
Curiosity Board | 1 |
Micro USB cable | 1 |
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.
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
- Precompiled
.hex
file is located in “<Harmony Content Path>wireless_apps_ble\apps\ble_hogps_app\hex\
” folder. - 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:
- Follow the steps mentioned in Running a Precompiled Example
- 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
- 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 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
- Create a new MCC Harmony Project by selecting the device. For more details, refer to Creating a New MCC Harmony Project.
- Launch the MCC from the toolbar
as illustrated below. The project graph will open with the default
components.
Figure 3-219. MCC - 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 - All BLE HOGPS related components will be added into the project graph. Accept dependencies or satisfiers by selecting Yes
- 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.
- For more details, refer to the link Configuring FreeRTOS in Getting Started with WME Bluetooth Low Energy Applications from Related Links.
- For WBZ451
- Change
WBZ451-CURIOSITY Component setting as illustrated in the
following figure
Figure 3-221. WBZ451-CURIOSITY Configuration - Change FreeRTOS
Component setting as illustrated in the following figure
Figure 3-222. FreeRTOS Configuration - Change
Device_Support Component setting as illustrated in the
following figure
Figure 3-223. Device_Support Configuration - Add TRNG Component
from Device
Resource>Libraries>Harmony>Peripherals>TRNG.
Figure 3-224. TRNG Component - Verify if the project
graph window has all the expected components, as illustrated in the
following figure:
Figure 3-225. Project Graph
- Change
WBZ451-CURIOSITY Component setting as illustrated in the
following figure
- For WBZ351
- Change
WBZ351-CURIOSITY Component setting as illustrated in the
following figure
Figure 3-226. WBZ351-CURIOSITY Configuration - Verify if the project
graph window has all the expected components, as illustrated in the
following figure:
Figure 3-227. Project Graph
- Change
WBZ351-CURIOSITY Component setting as illustrated in the
following figure
-
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 - 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
Generating a Code
For more details on code generation, refer to the MPLAB Code Configurator (MCC) Code Generation.
Files Containing User Application Code
Source Files | Usage |
---|---|
app.c | Application State machine, includes calls for Initialization of all BLE stack (GAP,GATT, SMP, L2CAP) related component configurations |
app_ble_callbacks.c | All the event functions related to GAP, GATT, SMP and L2CAP events that user can use or modify . |
app_hogps_callbacks.c | All the event functions related to HOGPS event handles that user can use or modify. |
app_utility.c | Contains generic utility functions that serve the purpose of providing reusable, common functionalities that can be applied across various parts of a program. |
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.app.c
app.c