Bluetooth LE discovery module
Use the Bluetooth® LE discovery module to discover GATT Services and read GATT Attribute Values from an nRF Desktop peripheral. The module is mandatory for the nRF Desktop central.
Module events
Source Module |
Input Event |
This Module |
Output Event |
Sink Module |
---|---|---|---|---|
|
|
|||
|
||||
|
||||
|
||||
|
Note
See the Overview: Firmware architecture for more information about the event-based communication in the nRF Desktop application and about how to read this table.
Configuration
Complete the following steps to configure the module:
Complete the basic Bluetooth configuration, as described in Bluetooth in nRF Desktop.
Make sure that the
CONFIG_BT_GATT_CLIENT
Kconfig option is enabled to support the GATT Client role.The module automatically selects the
CONFIG_BT_GATT_DM
Kconfig option to enable the GATT Discovery Manager. The GATT Discovery Manager is used by the Bluetooth® LE discovery module.Define the module configuration in the
ble_discovery_def.h
file, located in the board-specific directory in the application configuration directory. You must define the following parameters for every nRF Desktop peripheral that connects with the given nRF Desktop central:Parameters common for all the peripherals:
Vendor ID (VID)
Parameters defined separately for every peripheral:
Product ID (PID)
Peer type (
PEER_TYPE_MOUSE
orPEER_TYPE_KEYBOARD
)
For an example of the module configuration, see
configuration/nrf52840dongle_nrf52840/ble_discovery_def.h
.Note
The module configuration example uses
0x1915
as Nordic Semiconductor’s VID. Make sure to change this value to the VID of your company.The assigned PIDs should be unique for devices with the same VID.
Set the CONFIG_DESKTOP_BLE_DISCOVERY_ENABLE Kconfig option to enable the
ble_discovery
application module.
Implementation details
The Bluetooth® LE discovery module implementation is tasked with peripheral discovery and verification.
Peripheral discovery
The module starts the peripheral device discovery when it receives ble_peer_event
with ble_peer_event.state
set to PEER_STATE_CONNECTED
.
The peripheral discovery consists of the following steps:
Reading device description. The central checks if the connected peripheral supports the LLPM (Low Latency Packet Mode). The device description is a GATT Characteristic that is specific for nRF Desktop peripherals and is implemented by Device description module.
Reading Hardware ID (HW ID). The HW ID is unique per device and it is used to identify the device while forwarding the Configuration channel data. The HW ID is a read from a GATT Characteristic that is specific for nRF Desktop peripherals and is implemented by Device description module.
Reading DIS (Device Information Service). The central reads VID and PID of the connected peripheral.
HIDS (Human Interface Device Service) discovery. The central discovers HIDS and forwards the information to other application modules using
ble_discovery_complete
event. The HID forward module uses the event to register a new subscriber.
Note
Only one peripheral can be discovered at a time. The nRF Desktop central will not scan for new peripherals if a peripheral discovery is in progress.
Peripheral verification
If the connected peripheral does not provide one of the required GATT Characteristics, the central disconnects. The same actions are taken if the peripheral’s VID and PID value combination is unknown to the central.
The nRF Desktop central works only with predefined subset of peripherals.
The mentioned peripherals must be described in the ble_discovery_def.h
file.