nRF5 SDK v15.0.0
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
Human Interface Device Service

Human Interface Device Service module. More...

Modules

 Human Interface Device Service configuration
 

Data Structures

struct  ble_hids_char_id_t
 HID Service characteristic id. More...
 
struct  ble_hids_evt_t
 HID Service event. More...
 
struct  ble_hids_hid_information_t
 HID Information characteristic value. More...
 
struct  ble_hids_inp_rep_init_t
 HID Service Input Report characteristic init structure. This contains all options and data needed for initialization of one Input Report characteristic. More...
 
struct  ble_hids_outp_rep_init_t
 HID Service Output Report characteristic init structure. This contains all options and data needed for initialization of one Output Report characteristic. More...
 
struct  ble_hids_feature_rep_init_t
 HID Service Feature Report characteristic init structure. This contains all options and data needed for initialization of one Feature Report characteristic. More...
 
struct  ble_hids_rep_map_init_t
 HID Service Report Map characteristic init structure. This contains all options and data needed for initialization of the Report Map characteristic. More...
 
struct  ble_hids_rep_char_t
 HID Report characteristic structure. More...
 
struct  ble_hids_client_context_t
 HID Host context structure. It keeps information relevant to a single host. More...
 
struct  ble_hids_init_t
 HID Service init structure. This contains all options and data needed for initialization of the service. More...
 
struct  ble_hids_s
 HID Service structure. This contains various status information for the service. More...
 

Macros

#define BLE_HIDS_DEF(_name,_hids_max_clients,...)
 Allocate static data for keeping host connection contexts. More...
 
#define BLE_HIDS_LINK_CTX_SIZE_CALC(...)
 Helping macro for BLE_HIDS_DEF, that calculates the link context size for BLE HIDS instance. More...
 
#define BLE_HIDS_REPORT_ADD(_report_size)
 Helping macro for BLE_HIDS_LINK_CTX_SIZE_CALC, that adds Input/Output/Feature report lengths. More...
 
#define BLE_HIDS_MAX_INPUT_REP   10
 
#define BLE_HIDS_MAX_OUTPUT_REP   10
 
#define BLE_HIDS_MAX_FEATURE_REP   10
 
#define HID_INFO_FLAG_REMOTE_WAKE_MSK   0x01
 
#define HID_INFO_FLAG_NORMALLY_CONNECTABLE_MSK   0x02
 
#define BOOT_KB_INPUT_REPORT_MAX_SIZE   8
 
#define BOOT_KB_OUTPUT_REPORT_MAX_SIZE   1
 
#define BOOT_MOUSE_INPUT_REPORT_MIN_SIZE   3
 
#define BOOT_MOUSE_INPUT_REPORT_MAX_SIZE   8
 

Typedefs

typedef struct ble_hids_s ble_hids_t
 
typedef void(* ble_hids_evt_handler_t )(ble_hids_t *p_hids, ble_hids_evt_t *p_evt)
 HID Service event handler type.
 

Enumerations

enum  ble_hids_evt_type_t {
  BLE_HIDS_EVT_HOST_SUSP,
  BLE_HIDS_EVT_HOST_EXIT_SUSP,
  BLE_HIDS_EVT_NOTIF_ENABLED,
  BLE_HIDS_EVT_NOTIF_DISABLED,
  BLE_HIDS_EVT_REP_CHAR_WRITE,
  BLE_HIDS_EVT_BOOT_MODE_ENTERED,
  BLE_HIDS_EVT_REPORT_MODE_ENTERED,
  BLE_HIDS_EVT_REPORT_READ
}
 HID Service event type. More...
 

Functions

uint32_t ble_hids_init (ble_hids_t *p_hids, const ble_hids_init_t *p_hids_init)
 Function for initializing the HID Service. More...
 
void ble_hids_on_ble_evt (ble_evt_t const *p_ble_evt, void *p_context)
 Function for handling the Application's BLE Stack events. More...
 
uint32_t ble_hids_inp_rep_send (ble_hids_t *p_hids, uint8_t rep_index, uint16_t len, uint8_t *p_data, uint16_t conn_handle)
 Function for sending Input Report. More...
 
uint32_t ble_hids_boot_kb_inp_rep_send (ble_hids_t *p_hids, uint16_t len, uint8_t *p_data, uint16_t conn_handle)
 Function for sending Boot Keyboard Input Report. More...
 
uint32_t ble_hids_boot_mouse_inp_rep_send (ble_hids_t *p_hids, uint8_t buttons, int8_t x_delta, int8_t y_delta, uint16_t optional_data_len, uint8_t *p_optional_data, uint16_t conn_handle)
 Function for sending Boot Mouse Input Report. More...
 
uint32_t ble_hids_outp_rep_get (ble_hids_t *p_hids, uint8_t rep_index, uint16_t len, uint8_t offset, uint16_t conn_handle, uint8_t *p_outp_rep)
 Function for getting the current value of Output Report from the stack. More...
 

Report Type values

#define BLE_HIDS_REP_TYPE_INPUT   1
 
#define BLE_HIDS_REP_TYPE_OUTPUT   2
 
#define BLE_HIDS_REP_TYPE_FEATURE   3
 

Detailed Description

Human Interface Device Service module.

This module implements the Human Interface Device Service with the corresponding set of characteristics. During initialization it adds the Human Interface Device Service and a set of characteristics as per the Human Interface Device Service specification and the user requirements to the BLE stack database.

If enabled, notification of Input Report characteristics is performed when the application calls the corresponding ble_hids_xx_input_report_send() function.

If an event handler is supplied by the application, the Human Interface Device Service will generate Human Interface Device Service events to the application.

Note
The application must register this module as BLE event observer using the NRF_SDH_BLE_OBSERVER macro. Example:
Attention! To maintain compliance with Nordic Semiconductor ASA Bluetooth profile qualification listings, this section of source code must not be modified.

Macro Definition Documentation

#define BLE_HIDS_DEF (   _name,
  _hids_max_clients,
  ... 
)

Allocate static data for keeping host connection contexts.

Parameters
_nameName of BLE HIDS instance.
[in]_hids_max_clientsMaximum number of HIDS clients connected at a time.
[in]...Lengths of HIDS reports.

Mapping of HIDS reports in the HIDS report context:

  • Structure of type ble_hids_client_context_t
  • Boot keyboard input report
  • Boot keyboard output report
  • Boot mouse input report
  • Input reports
  • Output reports
  • Feature reports
#define BLE_HIDS_LINK_CTX_SIZE_CALC (   ...)

Helping macro for BLE_HIDS_DEF, that calculates the link context size for BLE HIDS instance.

Parameters
[in]...Lengths of HIDS reports
#define BLE_HIDS_REPORT_ADD (   _report_size)

Helping macro for BLE_HIDS_LINK_CTX_SIZE_CALC, that adds Input/Output/Feature report lengths.

Parameters
[in]_report_sizeLength of the specific report.
#define BOOT_KB_INPUT_REPORT_MAX_SIZE   8

Maximum size of a Boot Keyboard Input Report (as per Appendix B in Device Class Definition for Human Interface Devices (HID), Version 1.11).

#define BOOT_KB_OUTPUT_REPORT_MAX_SIZE   1

Maximum size of a Boot Keyboard Output Report (as per Appendix B in Device Class Definition for Human Interface Devices (HID), Version 1.11).

#define BOOT_MOUSE_INPUT_REPORT_MAX_SIZE   8

Maximum size of a Boot Mouse Input Report (as per Appendix B in Device Class Definition for Human Interface Devices (HID), Version 1.11).

#define BOOT_MOUSE_INPUT_REPORT_MIN_SIZE   3

Minimum size of a Boot Mouse Input Report (as per Appendix B in Device Class Definition for Human Interface Devices (HID), Version 1.11).

Enumeration Type Documentation

HID Service event type.

Enumerator
BLE_HIDS_EVT_HOST_SUSP 

Suspend command received.

BLE_HIDS_EVT_HOST_EXIT_SUSP 

Exit suspend command received.

BLE_HIDS_EVT_NOTIF_ENABLED 

Notification enabled event.

BLE_HIDS_EVT_NOTIF_DISABLED 

Notification disabled event.

BLE_HIDS_EVT_REP_CHAR_WRITE 

A new value has been written to an Report characteristic.

BLE_HIDS_EVT_BOOT_MODE_ENTERED 

Boot mode entered.

BLE_HIDS_EVT_REPORT_MODE_ENTERED 

Report mode entered.

BLE_HIDS_EVT_REPORT_READ 

Read with response

Function Documentation

uint32_t ble_hids_boot_kb_inp_rep_send ( ble_hids_t p_hids,
uint16_t  len,
uint8_t *  p_data,
uint16_t  conn_handle 
)

Function for sending Boot Keyboard Input Report.

Sends data on an Boot Keyboard Input Report characteristic.

Parameters
[in]p_hidsHID Service structure.
[in]lenLength of data to be sent.
[in]p_dataPointer to data to be sent.
[in]conn_handleConnection handle, where the notification will be sent.
Returns
NRF_SUCCESS on successful sending of the report, otherwise an error code.
uint32_t ble_hids_boot_mouse_inp_rep_send ( ble_hids_t p_hids,
uint8_t  buttons,
int8_t  x_delta,
int8_t  y_delta,
uint16_t  optional_data_len,
uint8_t *  p_optional_data,
uint16_t  conn_handle 
)

Function for sending Boot Mouse Input Report.

Sends data on an Boot Mouse Input Report characteristic.

Parameters
[in]p_hidsHID Service structure.
[in]buttonsState of mouse buttons.
[in]x_deltaHorizontal movement.
[in]y_deltaVertical movement.
[in]optional_data_lenLength of optional part of Boot Mouse Input Report.
[in]p_optional_dataOptional part of Boot Mouse Input Report.
[in]conn_handleConnection handle.
Returns
NRF_SUCCESS on successful sending of the report, otherwise an error code.
uint32_t ble_hids_init ( ble_hids_t p_hids,
const ble_hids_init_t p_hids_init 
)

Function for initializing the HID Service.

Parameters
[out]p_hidsHID Service structure. This structure will have to be supplied by the application. It will be initialized by this function, and will later be used to identify this particular service instance.
[in]p_hids_initInformation needed to initialize the service.
Returns
NRF_SUCCESS on successful initialization of service, otherwise an error code.
uint32_t ble_hids_inp_rep_send ( ble_hids_t p_hids,
uint8_t  rep_index,
uint16_t  len,
uint8_t *  p_data,
uint16_t  conn_handle 
)

Function for sending Input Report.

Sends data on an Input Report characteristic.

Parameters
[in]p_hidsHID Service structure.
[in]rep_indexIndex of the characteristic (corresponding to the index in ble_hids_t.inp_rep_array as passed to ble_hids_init()).
[in]lenLength of data to be sent.
[in]p_dataPointer to data to be sent.
[in]conn_handleConnection handle, where the notification will be sent.
Returns
NRF_SUCCESS on successful sending of input report, otherwise an error code.
void ble_hids_on_ble_evt ( ble_evt_t const *  p_ble_evt,
void *  p_context 
)

Function for handling the Application's BLE Stack events.

Handles all events from the BLE stack of interest to the HID Service.

Parameters
[in]p_ble_evtEvent received from the BLE stack.
[in]p_contextHID Service structure.
uint32_t ble_hids_outp_rep_get ( ble_hids_t p_hids,
uint8_t  rep_index,
uint16_t  len,
uint8_t  offset,
uint16_t  conn_handle,
uint8_t *  p_outp_rep 
)

Function for getting the current value of Output Report from the stack.

Fetches the current value of the output report characteristic from the stack.

Parameters
[in]p_hidsHID Service structure.
[in]rep_indexIndex of the characteristic (corresponding to the index in ble_hids_t.outp_rep_array as passed to ble_hids_init()).
[in]lenLength of output report needed.
[in]offsetOffset in bytes to read from.
[in]conn_handleConnection handle.
[out]p_outp_repPointer to the output report.
Returns
NRF_SUCCESS on successful read of the report, otherwise an error code.

Documentation feedback | Developer Zone | Subscribe | Updated