STM32WB0 Bluetooth® LE – human interface device

1. Human interface device over generic attribute profile

Human interface device over GATT profile (HOGP)[1] is a low-energy profile, based on the generic attribute profile (GATT) defined by the Bluetooth® special interest group (SIG)[2]

This profile is an adaptation of the USB human interface device (HID) specification[3] to operate over a Bluetooth® LE wireless link. This profile operates on Bluetooth® LE transport only.

The profile defines three roles:

  • The human interface device (HID) is a GATT server.
  • The boot host is a GATT client.
  • The report host is a GATT client.

Bluetooth® LE devices are not supported by PC BIOS, because the Bluetooth® LE stack and drivers are not loaded at this point yet, so the boot host role cannot be used with clients like PCs, smartphones, or tablets.

Bluetooth® LE HOGP: report host and HID device
STM32WB0 HOGP Profile


The report host supports the scan client role of the scan parameters profile.

The HID device has:

  • One or more instances of the HID service.
  • One or more instances of the battery service.
  • A single instance of the device information service.
  • Optionally, one instance of the scan parameters service as part of the scan server role of the scan parameters profile.
  • Optionally, a single or multiple instances of other services.

This wiki page describes the HID mouse and HID keyboard projects, provided with the STM32CubeWB0 MCU Package[4]

Bluetooth® LE HOGP mouse and keyboard profile with STM32WB0
STM32WB0 HID Mouse


The table below describes the structure of HOGP services:

Bluetooth® LE HOGP profile specification
Service Characteristic Mode UUID Size
HID service 0x1812
Input Report Read/Write/Notify 0x2A4D 80
Report Map Read 0x2A4B 2
HID information Read 0x2A4A 4
HID control point Write without response 0x2A4C 1
Device information service 0x180A
Manufacturer Name Read 0x2A29 32
Model Number Read 0x2A24 32
Firmware Revsion Read 0x2A26 32
Software Revsion Read 0x2A28 32
PnP ID Read 0x2A50 7
Battery service 0x180F
Battery level Read/Notify 0x2A19 1
Scan Parameter service 0x1813
Scan Interval Window Write without response 0x2A4F 4
Scan Refresh Notify 0x2A31 1

The table below describes the HID report characteristic descriptors:

Bluetooth® LE HID report characteristic descriptors specification
Characteristic name Descriptor name UUID Size
Report 0x2A4D
Client characteristic configuration descriptor​ 0x2902 1
Report reference descriptor 0x2908 2

The table below describes the battery level characteristic descriptor:

Bluetooth® LE battery level characteristic descriptor specification
Characteristic name Descriptor name UUID Size
Battery level 0x2A19
Client characteristic configuration descriptor​ 0x2902 1

The table below describes the Scan Refresh characteristic descriptors:

Bluetooth® LE scan refresh characteristic descriptor specification
Characteristic name Descriptor name UUID Size
Scan Refresh 0x2A19
Client characteristic configuration descriptor​ 0x2902 1



HOGP is a combination of a HID device and a report host to connect and exchange data in different applications.

The generic access profile (GAP) defines and manages advertising and connection.

Report host central device and HID peripheral device

STM32WBA55G-DK1 HOGP GAP


The generic attribute profile (GATT) defines and manages in/out data exchanges.

Report host GATT client device and HID GATT service device
STM32WB0 HOGP GATT


Examples of an HID flow diagram between a STM32WB0 Serire board and a Bluetooth® LE PC or Bluetooth® LE smartphone
STM32WB0 HID FLOW


1.1. STMicroelectronics manufacturer advertising data

At startup, HID device application (mouse/keyboard) starts fast advertising (80ms/100ms), including the STMicroelectronics manufacturer advertising elements[5] described below:

HID device STMicroelectronics manufacturer advertising data
0 1 2-3 4 5 6 7 8 9 10-15
Length Manufacturer ID Company BlueSTSDK Version Device ID Firmware ID Option 1 Option 2 Option 3 Device Address
HID Device 0x0F 0xFF 0x0030 STMicro 0x02 0x8D Nucleo-WB0 0x8B 0x00 0x00 0x00 0x08E12Axxxx

Advertising is switched to low-power advertising (1s/2.5s) after 60 seconds.

2. Requirements

2.1. Software and Hardware requirements

For software and hardware requirements refer to STM32WB0 Build BLE Project wiki page.

2.2. Collector applications compatible

The STM32CubeWB0 HID mouse project is compatible with the following collectors:

The STM32CubeWB0 HID keyboard project is compatible with the following collectors:

3. HID Mouse device example description

3.1. Project directory

The "BLE_HID_Mouse" application is available by downloading the STM32CubeWB0 MCU Package[6], in the following folder:

  • STM32Cube_FW_WB0_Vx.y.z\Projects\NUCLEO-WB05KZ\Applications\BLE\BLE_HID_Mouse
  • STM32Cube_FW_WB0_Vx.y.z\Projects\NUCLEO-WB07CC\Applications\BLE\BLE_HID_Mouse
  • STM32Cube_FW_WB0_Vx.y.z\Projects\NUCLEO-WB09KE\Applications\BLE\BLE_HID_Mouse

Refer to How to Build a Bluetooth® Low Energy project Wiki page for project directory information.

3.2. Project description

3.2.1. Structure

The figure below shows a software project structure, highlighting the most important parts:

HID mouse project structure
Connectivity WB0 HID PROJECT.png


3.2.2. Application initialization

The figure below details the different steps of the application initialization.

HID mouse project initialization
Connectivity WB0 HID PROJECT INIT.png

3.2.3. GAP and GATT initialization and interaction

The Bluetooth® LE HID mouse application initialization is done within app_ble.c.

  • Initialize the Bluetooth® LE stack, initialize the device as a peripheral, and configure and start advertising: ADV parameters, local name, and UUID - APP_BLE_init().
  • Call the services controller initialization BLEEVT_Init() - ble_evt.c.
  • Manage the GAP event - BLEEVT_App_Notification()
    • HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE- provides information of the connection interval, slave latency, supervision timeout
    • HCI_LE_CONNECTION_UPDATE_COMPLETE_SUBEVT_CODE- provides the new information of the connection
    • HCI_DISCONNECTION_COMPLETE_EVT_CODE- informs the application about the link disconnection and the reason

Event management is done by the Bluetoooth® LE Event Dispatcher, ble_evt.c.

  • Initialize the number of registered handler - BLEEVT_Init()
  • Manage events - BLE_STACK_Event() - from the Bluetooth® LE Host Stack and redirect them to the event handler - BLEEVT_App_Notification

The application level of the HID mouse device is done with hids_app.c.

  • Initialization of the services:
    • HID Service: HIDS_Init() in hids.c
  • Initialization of the context of the application:
    • Report map
    • HID information
  • Receive notifications from the HID service - HIDS_Notification().
  • When the remote enables the input report characteristic, it's possible to see the mouse pointer move in the display of paired computer or phone. This is a simulation of mouse movement: every 1 second the pointer moves on a fixed coordinate.

The HID service hids.c manages the specification of the service:

  • Service init (HIDS_Init()):
    • Registers the HID event handle to the service controller: BLEEVT_RegisterGattEvtHandler(HIDS_EventHandler).
    • Initializes the service UUID and adds the HID service as a primary service.
      • Initializes the report map characteristic.
      • Initializes the HID information characteristic.
  • Manages the GATT event from the Bluetooth® LE stack (HIDS_EventHandler()).
    • ACI_GATT_SRV_WRITE_VSEVT_CODE:
      • Reception of a write command: HID control point characteristic value.
        • Sending of an aci_gatt_srv_resp() with an OK or KO status.
        • Notification to the application to suspend or exit suspend (HIDS_Notification(HIDS_HCP_WRITE_NO_RESP_EVT)).
    • ACI_GATT_SRV_ATTRIBUTE_MODIFIED_VSEVT_CODE:
      • Reception of an attribute modification - input report characteristics description value: enable or disable notification.
        • Notify application of the input report notification (HIDS_Notification(HIDS_INPUTREP_NOTIFY_ENABLED_EVT/HIDS_INPUTREP_NOTIFY_DISABLED_EVT)).

3.2.4. Report map and input report

HID report map characteristics should contain the USB HID descriptor, specified in the USB HID specification[3].

A USB HID descriptor is a hard-coded array of bytes describing the data packets of the device, including:

  • The number of packets supported
  • The packet size
  • The purpose of each byte and bit in the packet

The figures below show an example of a USB mouse HID descriptor for a three-button mouse with X and Y axes and a wheel.

USB mouse HID descriptor
uint8_t reportDesc[] = {
  0x05, 0x01,        //USAGE_PAGE(Generic Desktop)
  0x09, 0x02,        //USAGE(Mouse)
  0xA1, 0x01,        //COLLECTION(Application)
  0x85, REPORT_ID,   // REPORT ID
  0x09, 0x01,        //USAGE(Pointer)
  0xA1, 0x00,        //COLLECTION(Physical)
  0x05, 0x09,        //USAGE_PAGE(Button)
  0x19, 0x01,        //USAGE_MINIMUM(Button 1)
  0x29, 0x03,        //USAGE_MAXIMUM(Button 3)
  0x15, 0x00,        //LOGICAL_MINIMUM(0)
  0x25, 0x01,        //LOGICAL_MAXIMUM(1)
  0x75, 0x01,        //REPORT_SIZE(1)
  0x95, 0x03,        //REPORT_COUNT(3)
  0x81, 0x02,        //INPUT(Data, Variable, Absolute) ; Button states
  0x75, 0x05,        //REPORT_SIZE(5)
  0x95, 0x01,        //REPORT_COUNT(1)
  0x81, 0x01,        //INPUT(Constant, Variable, Absolute) ; Reserved bits
  0x05, 0x01,        //USAGE_PAGE(Generic Desktop) 
  0x09, 0x30,        //USAGE(X)
  0x09, 0x31,        //USAGE(Y)
  0x16, 0x01, 0xF8,  //LOGICAL_MINIMUM(-2047)
  0x26, 0xFF, 0x07,  //LOGICAL_MAXIMUM(2047)
  0x75, 0x0C,        //REPORT_SIZE(12 bits)
  0x95, 0x02,        //REPORT_COUNT(2)
  0x81, 0x06,        //INPUT(Data, Variable, Relative) ; X & Y
  0x09, 0x38,        //USAGE(Z)
  0x15, 0x81,        //LOGICAL_MINIMUM(-127)
  0x25, 0x7F,        //LOGICAL_MAXIMUM(127)
  0x75, 0x08,        //REPORT_SIZE(8)
  0x95, 0x01,        //REPORT_COUNT(1)
  0x81, 0x06,        //INPUT(Data, Variable, Relative) ; Z
  0xC0,              //END_COLLECTION
  0xC0               //END_COLLECTION
};
Three-button mouse with X and Y axes and a wheel
Connectivity WBA HID 3-button mouse.png

All hard-coded bytes are described in the USB HID usage tables document[7].This USB HID descriptor also defines the data structure sent in the associated reports (input, output, or feature).

In this USB mouse HID descriptor example, you can find:

  • Highlighted in green, the definition of three buttons represented by the first three bits of a byte that can have the boolean state 0 or 1. Bits 0, 1, and 2 represent the states of respectively the left, middle, and right buttons of the mouse. The remaining bits of the byte are unused.
  • Highlighted in blue, the definition of three bytes for the X and Y axes for relative movement and wheel rotation. Each byte represents a signed integer that can take a value comprised between -127 to 127.

The figure below shows an example of the input report associated with the USB mouse HID descriptor.

Data structure for a three-button mouse with X and Y axes and a wheel
Connectivity WBA HID MOUSE INPUT REPORT.png

3.3. How to use the Bluetooth® LE HID mouse application

Once the Bluetooth® LE HID mouse application is installed on the STM32WB0 nucleo board, launch a Bluetooth® LE connection on a smartphone or a PC. Then, scan and connect the device called HID_XX (where XX is replaced by the last byte of the BD address) to the application.

3.3.1. Android Bluetooth® LE HID mouse

Android Bluetooth® LE HID mouse connection – How to
Connectivity WBA Smartphone Setting.png
Connectivity WBA Smartphone Device Connection.png
Connectivity WBA Smartphone Device Scanned.png
Connectivity WBA Smartphone Device Pairing.png
Connectivity WB0 Smartphone Device Connected.png

3.3.2. PC Bluetooth® LE HID mouse

PC Bluetooth® LE HID mouse – How to
Connectivity WBA HID PC SETTINGS.png
Connectivity WBA HID PC BLE DEVICES.png
PC Bluetooth® LE HID mouse – How to
Connectivity WBA HID PC ADD DEVICE.png
Connectivity WBA HID PC SCAN HID.png
PC Bluetooth® LE HID mouse – How to
Connectivity WBA HID PC CONNECT HID.png
PC HID CONNECTED
PC Bluetooth® LE HID mouse – How to
Connectivity WB0 HID PC HID CONNECTED2.png

3.3.3. Bluetooth® LE HID mouse how to

Once the Bluetooth® LE connection is established and the notification enabled by the smartphone or the PC, the HID input report is sent every 1 second and the smartphone or the PC pointer moves on a fixed coordinate (This is a simulation of mouse movement).

NUCLEO-WB05KZ/NUCLEO-WB07CC/NUCLEO-WB09KE are necessary to install the application.

Hardware platform illustration
NUCLEO-WB05KZ NUCLEO-WB07CC NUCLEO-WB09KE
Nucleo-WB05KZ

Nucleo-WB07CC

Nucleo-WB09KE

3.4. Low-power optimization

The project is delivered with the full system low-power feature disabled:

  • Debug trace enabled
  • Debugger enabled, even in Low-power mode

It is possible to enable/disable the low-power feature within app_conf.h:

/******************************************************************************
 * Low Power
 *
 *  When CFG_FULL_LOW_POWER is set to 1, the system is configured in full
 *  low power mode. It means that all what can have an impact on the consumptions
 *  are powered down.(For instance LED, Access to Debugger, Etc.)
 *
 *  When CFG_LPM_SUPPORTED and CFG_FULL_LOW_EMULATED are both set to 1, the system is configured to
 *  emulate the Deepstop mode without losing the debugger connection and breakpoints nor watchpoints.
 *
 ******************************************************************************/

#define CFG_FULL_LOW_POWER       (0)

#define CFG_LPM_SUPPORTED        (0)

#define CFG_LPM_EMULATED         (0)

3.5. UART debug trace

With the debug log via UART interface it is possible to trace the application project.

To enable the traces within the project, enable them in app_conf.h as described below:

/*****************************************************************************
 * Traces
 * Enable or Disable traces in application
 * When CFG_DEBUG_TRACE is set, traces are activated
 *
 * Note : Refer to utilities_conf.h file in order to details
 *        the level of traces : CFG_DEBUG_TRACE_FULL or CFG_DEBUG_TRACE_LIGHT
 *****************************************************************************/
/**
 * Enable or disable debug prints.
 */
#define CFG_DEBUG_APP_TRACE             (1)

/**
 * Use or not advanced trace module. UART interrupts to be enabled.
 */
#define CFG_DEBUG_APP_ADV_TRACE         (0)

#define ADV_TRACE_TIMESTAMP_ENABLE      (0)
HID mouse - initialization phase HID mouse - connected phase
 ==>> Start BLE_Init function
  Success: aci_hal_set_tx_power_level command
  Success: aci_gatt_srv_profile_init command
  Success: aci_gap_init command
  Static Random Bluetooth Address: e3:39:09:d2:dc:fb
  Success: Gap_profile_set_dev_name - Device Name
  Success: Gap_profile_set_appearance - Appearance
  Success: aci_gap_set_io_capability command
  Success: aci_gap_set_security_requirements command
  Success: aci_gap_configure_filter_accept_and_resolving_list command
==>> End BLE_Init function

Services and Characteristics creation
  Success: aci_gatt_srv_add_service command: HIDS
  Success: aci_gatt_srv_add_service command: DIS
  Success: aci_gatt_srv_add_service command: BAS
  Success: aci_gatt_srv_add_service command: SCPS
End of Services and Characteristics creation

==>> Success: aci_gap_set_advertising_configuration
==>> Success: aci_gap_set_advertising_data
==>> Success: aci_gap_set_advertising_enable
>>== hci_le_connection_complete_event - Connection handle: 0x0801
     - Connection established with @:7a:1b:79:e0:18:34
     - Connection Interval:   48.75 ms
     - Connection latency:    0
     - Supervision Timeout: 5000 ms
>>== HCI_LE_CONNECTION_UPDATE_COMPLETE_SUBEVT_CODE
     - Connection Interval:   7.50 ms
     - Connection latency:    0
     - Supervision Timeout:   5000 ms
HCI_EVENT: 0x08
>>== ACI_GAP_PAIRING_COMPLETE_VSEVT_CODE
     - Pairing Success

!!! Start virtual timer to update mouse coordinates!
HCI_VENDOR_EVT: 0x0C03
>>== HCI_LE_CONNECTION_UPDATE_COMPLETE_SUBEVT_CODE
     - Connection Interval:   48.75 ms
     - Connection latency:    0
     - Supervision Timeout:   5000 ms
Report Data: 0 - 32 - 0 - 0 - 0
  Success: aci_gatt_srv_notify INPUTREP command
Report Data: 0 - 0 - 20 - 3 - 0
  Success: aci_gatt_srv_notify INPUTREP command
Report Data: 0 - ce - f - 0 - 0
  Success: aci_gatt_srv_notify INPUTREP command
Report Data: 0 - 0 - e0 - fc - 0
  Success: aci_gatt_srv_notify INPUTREP command
Report Data: 0 - 32 - 0 - 0 - 0
  Success: aci_gatt_srv_notify INPUTREP command
Report Data: 0 - 0 - 20 - 3 - 0
  Success: aci_gatt_srv_notify INPUTREP command
Report Data: 0 - ce - f - 0 - 0
  Success: aci_gatt_srv_notify INPUTREP command
Report Data: 0 - 0 - e0 - fc - 0
  Success: aci_gatt_srv_notify INPUTREP command
Report Data: 0 - 32 - 0 - 0 - 0
  Success: aci_gatt_srv_notify INPUTREP command
Report Data: 0 - 0 - 20 - 3 - 0
  Success: aci_gatt_srv_notify INPUTREP command
Report Data: 0 - ce - f - 0 - 0
  Success: aci_gatt_srv_notify INPUTREP command
Report Data: 0 - 0 - e0 - fc - 0
  Success: aci_gatt_srv_notify INPUTREP command

4. HID Keyboard device example description

4.1. Project directory

The "BLE_HID_Keyboard" application is available by downloading the STM32CubeWB0 MCU Package[6], in the following folder:

  • STM32Cube_FW_WB0_Vx.y.z\Projects\NUCLEO-WB05KZ\Applications\BLE\BLE_HID_Keyboard
  • STM32Cube_FW_WB0_Vx.y.z\Projects\NUCLEO-WB07CC\Applications\BLE\BLE_HID_Keyboard
  • STM32Cube_FW_WB0_Vx.y.z\Projects\NUCLEO-WB09KE\Applications\BLE\BLE_HID_Keyboard

Refer to How to Build a Bluetooth® LE project Wiki page for project directory information.

4.2. Project description

4.2.1. Structure

The figure below shows a software project structure, highlighting the most important parts:

HID Keyboard project structure
Connectivity WB0 HID Keyboard PROJECT.png


4.2.2. Application initialization

The figure below details the different steps of the application initialization.

HID Keyboard project initialization
Connectivity WB0 HID PROJECT INIT.png

4.2.3. GAP and GATT initialization and interaction

The Bluetooth® LE HID Keyboard application initialization is done within app_ble.c.

  • Initialize the Bluetooth® LE stack, initialize the device as a peripheral, and configure and start advertising: ADV parameters, local name, and UUID - APP_BLE_init().
  • Call the services controller initialization BLEEVT_Init() - ble_evt.c.
  • Manage the GAP event - BLEEVT_App_Notification()
    • HCI_LE_CONNECTION_COMPLETE_SUBEVT_CODE- provides information of the connection interval, slave latency, supervision timeout
    • HCI_LE_CONNECTION_UPDATE_COMPLETE_SUBEVT_CODE- provides the new information of the connection
    • HCI_DISCONNECTION_COMPLETE_EVT_CODE- informs the application about the link disconnection and the reason

Event management is done by the Bluetoooth® LE Event Dispatcher, ble_evt.c.

  • Initialize the number of registered handler - BLEEVT_Init()
  • Manage events - BLE_STACK_Event() - from the Bluetooth® LE Host Stack and redirect them to the event handler - BLEEVT_App_Notification

The application level of the HID mouse device is done with hids_app.c.

  • Initialization of the services:
    • HID Service: HIDS_Init() in hids.c
  • Initialization of the context of the application:
    • Report map
    • HID information
  • Receive notifications from the HID service - HIDS_Notification().

The HID service hids.c manages the specification of the service:

  • Service init (HIDS_Init()):
    • Registers the HID event handle to the service controller: BLEEVT_RegisterGattEvtHandler(HIDS_EventHandler).
    • Initializes the service UUID and adds the HID service as a primary service.
      • Initializes the report map characteristic.
      • Initializes the HID information characteristic.
  • Manages the GATT event from the Bluetooth® LE stack (HIDS_EventHandler()).
    • ACI_GATT_SRV_WRITE_VSEVT_CODE:
      • Reception of a write command: HID control point characteristic value.
        • Sending of an aci_gatt_srv_resp() with an OK or KO status.
        • Notification to the application to suspend or exit suspend (HIDS_Notification(HIDS_HCP_WRITE_NO_RESP_EVT)).
    • ACI_GATT_SRV_ATTRIBUTE_MODIFIED_VSEVT_CODE:
      • Reception of an attribute modification - input report characteristics description value: enable or disable notification.
        • Notify application of the input report notification (HIDS_Notification(HIDS_INPUTREP_NOTIFY_ENABLED_EVT/HIDS_INPUTREP_NOTIFY_DISABLED_EVT)).

4.2.4. Report map and input report

HID report map characteristics should contain the USB HID descriptor, specified in the USB HID specification[3].

A USB HID descriptor is a hard-coded array of bytes describing the data packets of the device, including:

  • The number of packets supported
  • The packet size
  • The purpose of each byte and bit in the packet

The figures below show an example of a USB keyboard HID descriptor.

USB keyboard HID descriptor
uint8_t reportDesc[] = {
    0x05, 0x01,                 // Usage Page (Generic Desktop)        
	0x09, 0x06,                 // Usage (Keyboard)        
	0xA1, 0x01,                 // Collection (Application)        
	0x05, 0x07,                 //     Usage Page (Key Codes)        
	0x19, 0xe0,                 //     Usage Minimum (224)        
	0x29, 0xe7,                 //     Usage Maximum (231)        
	0x15, 0x00,                 //     Logical Minimum (0)        
	0x25, 0x01,                 //     Logical Maximum (1)        
	0x75, 0x01,                 //     Report Size (1)        
	0x95, 0x08,                 //     Report Count (8)        
	0x81, 0x02,                 //     Input (Data, Variable, Absolute)            
	0x95, 0x01,                 //     Report Count (1)        
	0x75, 0x08,                 //     Report Size (8)        
	0x81, 0x01,                 //     Input (Constant) reserved byte(1)            
	0x95, 0x05,                 //     Report Count (5)        
	0x75, 0x01,                 //     Report Size (1)        
	0x05, 0x08,                 //     Usage Page (Page# for LEDs)        
	0x19, 0x01,                 //     Usage Minimum (1)        
	0x29, 0x05,                 //     Usage Maximum (5)        
	0x91, 0x02,                 //     Output (Data, Variable, Absolute), Led report        
	0x95, 0x01,                 //     Report Count (1)        
	0x75, 0x03,                 //     Report Size (3)        
	0x91, 0x01,                 //     Output (Data, Variable, Absolute), Led report padding
	0x95, 0x06,                 //     Report Count (6)        
	0x75, 0x08,                 //     Report Size (8)        
	0x15, 0x00,                 //     Logical Minimum (0)        
	0x25, 0x65,                 //     Logical Maximum (101)        
	0x05, 0x07,                 //     Usage Page (Key codes)        
	0x19, 0x00,                 //     Usage Minimum (0)        
	0x29, 0x65,                 //     Usage Maximum (101)        
	0x81, 0x00,                 //     Input (Data, Array) Key array(6 bytes)            
	0x09, 0x05,                 //     Usage (Vendor Defined)        
	0x15, 0x00,                 //     Logical Minimum (0)        
	0x26, 0xFF, 0x00,           //     Logical Maximum (255)        
	0x75, 0x08,                 //     Report Count (2)        
	0x95, 0x02,                 //     Report Size (8 bit)        
	0xB1, 0x02,                 //     Feature (Data, Variable, Absolute)        
	0xC0                        // End Collection (Application)    
};


All hard-coded bytes are described in the USB HID usage tables document[7]. This USB HID descriptor also defines the data structure sent in the associated reports (input, output, or feature).

4.3. How to use the Bluetooth® LE HID keyboard application

Once the Bluetooth® LE HID keyboard application is installed on the STM32WB0 nucleo board, launch a Bluetooth® LE connection on a smartphone or a PC. Then, scan and connect the device called HID_XX (where XX is replaced by the last byte of the BD address) to the application.

4.3.1. Android Bluetooth® LE HID keyboard

Android Bluetooth® LE HID keyboard connection – How to
Connectivity WBA Smartphone Setting.png
Connectivity WBA Smartphone Device Connection.png
Connectivity WBA Smartphone Device Scanned.png
Connectivity WBA Smartphone Device Pairing.png
Connectivity WB0 Smartphone Device Connected.png

4.3.2. PC Bluetooth® LE HID keyboard

PC Bluetooth® LE HID keyboard – How to
Connectivity WBA HID PC SETTINGS.png
Connectivity WBA HID PC BLE DEVICES.png
PC Bluetooth® LE HID keyboard – How to
Connectivity WBA HID PC ADD DEVICE.png
Connectivity WBA HID PC SCAN HID.png
PC Bluetooth® LE HID keyboard – How to
Connectivity WBA HID PC CONNECT HID.png
PC HID CONNECTED
PC Bluetooth® LE HID keyboard – How to
Connectivity WB0 HID KEYBOARD PC HID CONNECTED2.png

4.3.3. Bluetooth® LE HID keyboard how to

Once the Bluetooth® LE connection is established and the devices are bonded, it is possible to enter data using keyboard on serial terminal: each char is sent to peer device.

NUCLEO-WB05KZ/NUCLEO-WB07CC/NUCLEO-WB09KE are necessary to install the application.

Hardware platform illustration
NUCLEO-WB05KZ NUCLEO-WB07CC NUCLEO-WB09KE
Nucleo-WB05KZ

Nucleo-WB07CC

Nucleo-WB09KE

4.4. Low-power optimization

The project is delivered with the full system low-power feature disabled:

  • Debug trace enabled
  • Debugger enabled, even in Low-power mode

It is possible to enable/disable the low-power feature within app_conf.h:

/******************************************************************************
 * Low Power
 *
 *  When CFG_FULL_LOW_POWER is set to 1, the system is configured in full
 *  low power mode. It means that all what can have an impact on the consumptions
 *  are powered down.(For instance LED, Access to Debugger, Etc.)
 *
 *  When CFG_LPM_SUPPORTED and CFG_FULL_LOW_EMULATED are both set to 1, the system is configured to
 *  emulate the Deepstop mode without losing the debugger connection and breakpoints nor watchpoints.
 *
 ******************************************************************************/

#define CFG_FULL_LOW_POWER       (0)

#define CFG_LPM_SUPPORTED        (0)

#define CFG_LPM_EMULATED         (0)

4.5. UART debug trace

With the debug log via UART interface it is possible to trace the application project.

To enable the traces within the project, enable them in app_conf.h as described below:

/*****************************************************************************
 * Traces
 * Enable or Disable traces in application
 * When CFG_DEBUG_TRACE is set, traces are activated
 *
 * Note : Refer to utilities_conf.h file in order to details
 *        the level of traces : CFG_DEBUG_TRACE_FULL or CFG_DEBUG_TRACE_LIGHT
 *****************************************************************************/
/**
 * Enable or disable debug prints.
 */
#define CFG_DEBUG_APP_TRACE             (1)

/**
 * Use or not advanced trace module. UART interrupts to be enabled.
 */
#define CFG_DEBUG_APP_ADV_TRACE         (0)

#define ADV_TRACE_TIMESTAMP_ENABLE      (0)
HID keyboard - initialization phase HID keyboard - connected phase
 ==>> Start BLE_Init function
  Success: aci_hal_set_tx_power_level command
  Success: aci_gatt_srv_profile_init command
  Success: aci_gap_init command
  Static Random Bluetooth Address: ea:a4:97:ab:53:79
  Success: Gap_profile_set_dev_name - Device Name
  Success: Gap_profile_set_appearance - Appearance
  Success: aci_gap_set_io_capability command
  Success: aci_gap_set_security_requirements command
  Success: aci_gap_configure_filter_accept_and_resolving_list command
==>> End BLE_Init function

Services and Characteristics creation
  Success: aci_gatt_srv_add_service command: HIDS
  Success: aci_gatt_srv_add_service command: DIS
  Success: aci_gatt_srv_add_service command: BAS
  Success: aci_gatt_srv_add_service command: SCPS
End of Services and Characteristics creation

==>> Success: aci_gap_set_advertising_configuration
==>> Success: aci_gap_set_advertising_data
==>> Success: aci_gap_set_advertising_enable
HCI_LE_META_EVT: 0x14
>>== hci_le_connection_complete_event - Connection handle: 0x0801
     - Connection established with @:6d:00:92:22:c7:72
     - Connection Interval:   48.75 ms
     - Connection latency:    0
     - Supervision Timeout: 5000 ms
HCI_LE_META_EVT: 0x08
HCI_LE_META_EVT: 0x09
HCI_EVENT: 0x08
>>== ACI_GAP_PAIRING_COMPLETE_VSEVT_CODE
     - Pairing Success

>>== HCI_LE_CONNECTION_UPDATE_COMPLETE_SUBEVT_CODE
     - Connection Interval:   7.50 ms
     - Connection latency:    0
     - Supervision Timeout:   5000 ms
HCI_VENDOR_EVT: 0x0C01
>>== HCI_LE_CONNECTION_UPDATE_COMPLETE_SUBEVT_CODE
     - Connection Interval:   48.75 ms
     - Connection latency:    0
     - Supervision Timeout:   5000 ms
ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE HIDS_INPUTREP_NOTIFY_ENABLED_EVT
HIDS_INPUTREP_NOTIFY_ENABLED_EVT
g  Success: aci_gatt_srv_notify INPUTREP command
  Success: aci_gatt_srv_notify INPUTREP command
e  Success: aci_gatt_srv_notify INPUTREP command
  Success: aci_gatt_srv_notify INPUTREP command
t  Success: aci_gatt_srv_notify INPUTREP command
  Success: aci_gatt_srv_notify INPUTREP command


5. References