Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_WallbotBLE_Challenge_byYUTAKA3 by
nRF51822/nordic/nrf-sdk/ble/ble_services/ble_hids.h@0:76dfa9657d9d, 2014-11-12 (annotated)
- Committer:
- jksoft
- Date:
- Wed Nov 12 02:40:34 2014 +0000
- Revision:
- 0:76dfa9657d9d
????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jksoft | 0:76dfa9657d9d | 1 | /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved. |
jksoft | 0:76dfa9657d9d | 2 | * |
jksoft | 0:76dfa9657d9d | 3 | * The information contained herein is property of Nordic Semiconductor ASA. |
jksoft | 0:76dfa9657d9d | 4 | * Terms and conditions of usage are described in detail in NORDIC |
jksoft | 0:76dfa9657d9d | 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. |
jksoft | 0:76dfa9657d9d | 6 | * |
jksoft | 0:76dfa9657d9d | 7 | * Licensees are granted free, non-transferable use of the information. NO |
jksoft | 0:76dfa9657d9d | 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from |
jksoft | 0:76dfa9657d9d | 9 | * the file. |
jksoft | 0:76dfa9657d9d | 10 | * |
jksoft | 0:76dfa9657d9d | 11 | */ |
jksoft | 0:76dfa9657d9d | 12 | |
jksoft | 0:76dfa9657d9d | 13 | /** @file |
jksoft | 0:76dfa9657d9d | 14 | * |
jksoft | 0:76dfa9657d9d | 15 | * @defgroup ble_sdk_srv_hids Human Interface Device Service |
jksoft | 0:76dfa9657d9d | 16 | * @{ |
jksoft | 0:76dfa9657d9d | 17 | * @ingroup ble_sdk_srv |
jksoft | 0:76dfa9657d9d | 18 | * @brief Human Interface Device Service module. |
jksoft | 0:76dfa9657d9d | 19 | * |
jksoft | 0:76dfa9657d9d | 20 | * @details This module implements the Human Interface Device Service with the corresponding set of |
jksoft | 0:76dfa9657d9d | 21 | * characteristics. During initialization it adds the Human Interface Device Service and |
jksoft | 0:76dfa9657d9d | 22 | * a set of characteristics as per the Human Interface Device Service specification and |
jksoft | 0:76dfa9657d9d | 23 | * the user requirements to the BLE stack database. |
jksoft | 0:76dfa9657d9d | 24 | * |
jksoft | 0:76dfa9657d9d | 25 | * If enabled, notification of Input Report characteristics is performed when the |
jksoft | 0:76dfa9657d9d | 26 | * application calls the corresponding ble_hids_xx_input_report_send() function. |
jksoft | 0:76dfa9657d9d | 27 | * |
jksoft | 0:76dfa9657d9d | 28 | * If an event handler is supplied by the application, the Human Interface Device Service |
jksoft | 0:76dfa9657d9d | 29 | * will generate Human Interface Device Service events to the application. |
jksoft | 0:76dfa9657d9d | 30 | * |
jksoft | 0:76dfa9657d9d | 31 | * @note The application must propagate BLE stack events to the Human Interface Device Service |
jksoft | 0:76dfa9657d9d | 32 | * module by calling ble_hids_on_ble_evt() from the @ref ble_stack_handler callback. |
jksoft | 0:76dfa9657d9d | 33 | * |
jksoft | 0:76dfa9657d9d | 34 | * @note Attention! |
jksoft | 0:76dfa9657d9d | 35 | * To maintain compliance with Nordic Semiconductor ASA Bluetooth profile |
jksoft | 0:76dfa9657d9d | 36 | * qualification listings, this section of source code must not be modified. |
jksoft | 0:76dfa9657d9d | 37 | */ |
jksoft | 0:76dfa9657d9d | 38 | |
jksoft | 0:76dfa9657d9d | 39 | #ifndef BLE_HIDS_H__ |
jksoft | 0:76dfa9657d9d | 40 | #define BLE_HIDS_H__ |
jksoft | 0:76dfa9657d9d | 41 | |
jksoft | 0:76dfa9657d9d | 42 | #include <stdint.h> |
jksoft | 0:76dfa9657d9d | 43 | #include <stdbool.h> |
jksoft | 0:76dfa9657d9d | 44 | #include "ble.h" |
jksoft | 0:76dfa9657d9d | 45 | #include "ble_srv_common.h" |
jksoft | 0:76dfa9657d9d | 46 | |
jksoft | 0:76dfa9657d9d | 47 | // Report Type values |
jksoft | 0:76dfa9657d9d | 48 | #define BLE_HIDS_REP_TYPE_INPUT 1 |
jksoft | 0:76dfa9657d9d | 49 | #define BLE_HIDS_REP_TYPE_OUTPUT 2 |
jksoft | 0:76dfa9657d9d | 50 | #define BLE_HIDS_REP_TYPE_FEATURE 3 |
jksoft | 0:76dfa9657d9d | 51 | |
jksoft | 0:76dfa9657d9d | 52 | // Maximum number of the various Report Types |
jksoft | 0:76dfa9657d9d | 53 | #define BLE_HIDS_MAX_INPUT_REP 10 |
jksoft | 0:76dfa9657d9d | 54 | #define BLE_HIDS_MAX_OUTPUT_REP 10 |
jksoft | 0:76dfa9657d9d | 55 | #define BLE_HIDS_MAX_FEATURE_REP 10 |
jksoft | 0:76dfa9657d9d | 56 | |
jksoft | 0:76dfa9657d9d | 57 | // Information Flags |
jksoft | 0:76dfa9657d9d | 58 | #define HID_INFO_FLAG_REMOTE_WAKE_MSK 0x01 |
jksoft | 0:76dfa9657d9d | 59 | #define HID_INFO_FLAG_NORMALLY_CONNECTABLE_MSK 0x02 |
jksoft | 0:76dfa9657d9d | 60 | |
jksoft | 0:76dfa9657d9d | 61 | /**@brief HID Service characteristic id. */ |
jksoft | 0:76dfa9657d9d | 62 | typedef struct |
jksoft | 0:76dfa9657d9d | 63 | { |
jksoft | 0:76dfa9657d9d | 64 | uint16_t uuid; /**< UUID of characteristic. */ |
jksoft | 0:76dfa9657d9d | 65 | uint8_t rep_type; /**< Type of report (only used for BLE_UUID_REPORT_CHAR, see @ref BLE_HIDS_REPORT_TYPE). */ |
jksoft | 0:76dfa9657d9d | 66 | uint8_t rep_index; /**< Index of the characteristic (only used for BLE_UUID_REPORT_CHAR). */ |
jksoft | 0:76dfa9657d9d | 67 | } ble_hids_char_id_t; |
jksoft | 0:76dfa9657d9d | 68 | |
jksoft | 0:76dfa9657d9d | 69 | /**@brief HID Service event type. */ |
jksoft | 0:76dfa9657d9d | 70 | typedef enum |
jksoft | 0:76dfa9657d9d | 71 | { |
jksoft | 0:76dfa9657d9d | 72 | BLE_HIDS_EVT_HOST_SUSP, /**< Suspend command received. */ |
jksoft | 0:76dfa9657d9d | 73 | BLE_HIDS_EVT_HOST_EXIT_SUSP, /**< Exit suspend command received. */ |
jksoft | 0:76dfa9657d9d | 74 | BLE_HIDS_EVT_NOTIF_ENABLED, /**< Notification enabled event. */ |
jksoft | 0:76dfa9657d9d | 75 | BLE_HIDS_EVT_NOTIF_DISABLED, /**< Notification disabled event. */ |
jksoft | 0:76dfa9657d9d | 76 | BLE_HIDS_EVT_REP_CHAR_WRITE, /**< A new value has been written to an Report characteristic. */ |
jksoft | 0:76dfa9657d9d | 77 | BLE_HIDS_EVT_BOOT_MODE_ENTERED, /**< Boot mode entered. */ |
jksoft | 0:76dfa9657d9d | 78 | BLE_HIDS_EVT_REPORT_MODE_ENTERED, /**< Report mode entered. */ |
jksoft | 0:76dfa9657d9d | 79 | BLE_HIDS_EVT_REPORT_READ /**< Read with response */ |
jksoft | 0:76dfa9657d9d | 80 | } ble_hids_evt_type_t; |
jksoft | 0:76dfa9657d9d | 81 | |
jksoft | 0:76dfa9657d9d | 82 | /**@brief HID Service event. */ |
jksoft | 0:76dfa9657d9d | 83 | typedef struct |
jksoft | 0:76dfa9657d9d | 84 | { |
jksoft | 0:76dfa9657d9d | 85 | ble_hids_evt_type_t evt_type; /**< Type of event. */ |
jksoft | 0:76dfa9657d9d | 86 | union |
jksoft | 0:76dfa9657d9d | 87 | { |
jksoft | 0:76dfa9657d9d | 88 | struct |
jksoft | 0:76dfa9657d9d | 89 | { |
jksoft | 0:76dfa9657d9d | 90 | ble_hids_char_id_t char_id; /**< Id of characteristic for which notification has been started. */ |
jksoft | 0:76dfa9657d9d | 91 | } notification; |
jksoft | 0:76dfa9657d9d | 92 | struct |
jksoft | 0:76dfa9657d9d | 93 | { |
jksoft | 0:76dfa9657d9d | 94 | ble_hids_char_id_t char_id; /**< Id of characteristic having been written. */ |
jksoft | 0:76dfa9657d9d | 95 | uint16_t offset; /**< Offset for the write operation. */ |
jksoft | 0:76dfa9657d9d | 96 | uint16_t len; /**< Length of the incoming data. */ |
jksoft | 0:76dfa9657d9d | 97 | uint8_t* data; /**< Incoming data, variable length */ |
jksoft | 0:76dfa9657d9d | 98 | } char_write; |
jksoft | 0:76dfa9657d9d | 99 | struct |
jksoft | 0:76dfa9657d9d | 100 | { |
jksoft | 0:76dfa9657d9d | 101 | ble_hids_char_id_t char_id; /**< Id of characteristic being read. */ |
jksoft | 0:76dfa9657d9d | 102 | } char_auth_read; |
jksoft | 0:76dfa9657d9d | 103 | } params; |
jksoft | 0:76dfa9657d9d | 104 | ble_evt_t * p_ble_evt; /**< corresponding received ble event, NULL if not relevant */ |
jksoft | 0:76dfa9657d9d | 105 | } ble_hids_evt_t; |
jksoft | 0:76dfa9657d9d | 106 | |
jksoft | 0:76dfa9657d9d | 107 | // Forward declaration of the ble_hids_t type. |
jksoft | 0:76dfa9657d9d | 108 | typedef struct ble_hids_s ble_hids_t; |
jksoft | 0:76dfa9657d9d | 109 | |
jksoft | 0:76dfa9657d9d | 110 | /**@brief HID Service event handler type. */ |
jksoft | 0:76dfa9657d9d | 111 | typedef void (*ble_hids_evt_handler_t) (ble_hids_t * p_hids, ble_hids_evt_t * p_evt); |
jksoft | 0:76dfa9657d9d | 112 | |
jksoft | 0:76dfa9657d9d | 113 | /**@brief HID Information characteristic value. */ |
jksoft | 0:76dfa9657d9d | 114 | typedef struct |
jksoft | 0:76dfa9657d9d | 115 | { |
jksoft | 0:76dfa9657d9d | 116 | uint16_t bcd_hid; /**< 16-bit unsigned integer representing version number of base USB HID Specification implemented by HID Device */ |
jksoft | 0:76dfa9657d9d | 117 | uint8_t b_country_code; /**< Identifies which country the hardware is localized for. Most hardware is not localized and thus this value would be zero (0). */ |
jksoft | 0:76dfa9657d9d | 118 | uint8_t flags; /**< See http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.hid_information.xml */ |
jksoft | 0:76dfa9657d9d | 119 | ble_srv_security_mode_t security_mode; /**< Security mode for the HID Information characteristic. */ |
jksoft | 0:76dfa9657d9d | 120 | } ble_hids_hid_information_t; |
jksoft | 0:76dfa9657d9d | 121 | |
jksoft | 0:76dfa9657d9d | 122 | /**@brief HID Service Input Report characteristic init structure. This contains all options and |
jksoft | 0:76dfa9657d9d | 123 | * data needed for initialization of one Input Report characteristic. */ |
jksoft | 0:76dfa9657d9d | 124 | typedef struct |
jksoft | 0:76dfa9657d9d | 125 | { |
jksoft | 0:76dfa9657d9d | 126 | uint16_t max_len; /**< Maximum length of characteristic value. */ |
jksoft | 0:76dfa9657d9d | 127 | ble_srv_report_ref_t rep_ref; /**< Value of the Report Reference descriptor. */ |
jksoft | 0:76dfa9657d9d | 128 | ble_srv_cccd_security_mode_t security_mode; /**< Security mode for the HID Input Report characteristic, including cccd. */ |
jksoft | 0:76dfa9657d9d | 129 | uint8_t read_resp : 1; /**< Should application generate a response to read requests. */ |
jksoft | 0:76dfa9657d9d | 130 | } ble_hids_inp_rep_init_t; |
jksoft | 0:76dfa9657d9d | 131 | |
jksoft | 0:76dfa9657d9d | 132 | /**@brief HID Service Output Report characteristic init structure. This contains all options and |
jksoft | 0:76dfa9657d9d | 133 | * data needed for initialization of one Output Report characteristic. */ |
jksoft | 0:76dfa9657d9d | 134 | typedef struct |
jksoft | 0:76dfa9657d9d | 135 | { |
jksoft | 0:76dfa9657d9d | 136 | uint16_t max_len; /**< Maximum length of characteristic value. */ |
jksoft | 0:76dfa9657d9d | 137 | ble_srv_report_ref_t rep_ref; /**< Value of the Report Reference descriptor. */ |
jksoft | 0:76dfa9657d9d | 138 | ble_srv_cccd_security_mode_t security_mode; /**< Security mode for the HID Output Report characteristic, including cccd. */ |
jksoft | 0:76dfa9657d9d | 139 | uint8_t read_resp : 1; /**< Should application generate a response to read requests. */ |
jksoft | 0:76dfa9657d9d | 140 | } ble_hids_outp_rep_init_t; |
jksoft | 0:76dfa9657d9d | 141 | |
jksoft | 0:76dfa9657d9d | 142 | /**@brief HID Service Feature Report characteristic init structure. This contains all options and |
jksoft | 0:76dfa9657d9d | 143 | * data needed for initialization of one Feature Report characteristic. */ |
jksoft | 0:76dfa9657d9d | 144 | typedef struct |
jksoft | 0:76dfa9657d9d | 145 | { |
jksoft | 0:76dfa9657d9d | 146 | uint16_t max_len; /**< Maximum length of characteristic value. */ |
jksoft | 0:76dfa9657d9d | 147 | ble_srv_report_ref_t rep_ref; /**< Value of the Report Reference descriptor. */ |
jksoft | 0:76dfa9657d9d | 148 | ble_srv_cccd_security_mode_t security_mode; /**< Security mode for the HID Service Feature Report characteristic, including cccd. */ |
jksoft | 0:76dfa9657d9d | 149 | uint8_t read_resp : 1; /**< Should application generate a response to read requests. */ |
jksoft | 0:76dfa9657d9d | 150 | } ble_hids_feature_rep_init_t; |
jksoft | 0:76dfa9657d9d | 151 | |
jksoft | 0:76dfa9657d9d | 152 | /**@brief HID Service Report Map characteristic init structure. This contains all options and data |
jksoft | 0:76dfa9657d9d | 153 | * needed for initialization of the Report Map characteristic. */ |
jksoft | 0:76dfa9657d9d | 154 | typedef struct |
jksoft | 0:76dfa9657d9d | 155 | { |
jksoft | 0:76dfa9657d9d | 156 | uint8_t * p_data; /**< Report map data. */ |
jksoft | 0:76dfa9657d9d | 157 | uint16_t data_len; /**< Length of report map data. */ |
jksoft | 0:76dfa9657d9d | 158 | uint8_t ext_rep_ref_num; /**< Number of Optional External Report Reference descriptors. */ |
jksoft | 0:76dfa9657d9d | 159 | ble_uuid_t * p_ext_rep_ref; /**< Optional External Report Reference descriptor (will be added if != NULL). */ |
jksoft | 0:76dfa9657d9d | 160 | ble_srv_security_mode_t security_mode; /**< Security mode for the HID Service Report Map characteristic. */ |
jksoft | 0:76dfa9657d9d | 161 | } ble_hids_rep_map_init_t; |
jksoft | 0:76dfa9657d9d | 162 | |
jksoft | 0:76dfa9657d9d | 163 | /**@brief HID Report characteristic structure. */ |
jksoft | 0:76dfa9657d9d | 164 | typedef struct |
jksoft | 0:76dfa9657d9d | 165 | { |
jksoft | 0:76dfa9657d9d | 166 | ble_gatts_char_handles_t char_handles; /**< Handles related to the Report characteristic. */ |
jksoft | 0:76dfa9657d9d | 167 | uint16_t ref_handle; /**< Handle of the Report Reference descriptor. */ |
jksoft | 0:76dfa9657d9d | 168 | } ble_hids_rep_char_t; |
jksoft | 0:76dfa9657d9d | 169 | |
jksoft | 0:76dfa9657d9d | 170 | /**@brief HID Service init structure. This contains all options and data needed for initialization |
jksoft | 0:76dfa9657d9d | 171 | * of the service. */ |
jksoft | 0:76dfa9657d9d | 172 | typedef struct |
jksoft | 0:76dfa9657d9d | 173 | { |
jksoft | 0:76dfa9657d9d | 174 | ble_hids_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the HID Service. */ |
jksoft | 0:76dfa9657d9d | 175 | ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ |
jksoft | 0:76dfa9657d9d | 176 | bool is_kb; /**< TRUE if device is operating as a keyboard, FALSE if it is not. */ |
jksoft | 0:76dfa9657d9d | 177 | bool is_mouse; /**< TRUE if device is operating as a mouse, FALSE if it is not. */ |
jksoft | 0:76dfa9657d9d | 178 | uint8_t inp_rep_count; /**< Number of Input Report characteristics. */ |
jksoft | 0:76dfa9657d9d | 179 | ble_hids_inp_rep_init_t * p_inp_rep_array; /**< Information about the Input Report characteristics. */ |
jksoft | 0:76dfa9657d9d | 180 | uint8_t outp_rep_count; /**< Number of Output Report characteristics. */ |
jksoft | 0:76dfa9657d9d | 181 | ble_hids_outp_rep_init_t * p_outp_rep_array; /**< Information about the Output Report characteristics. */ |
jksoft | 0:76dfa9657d9d | 182 | uint8_t feature_rep_count; /**< Number of Feature Report characteristics. */ |
jksoft | 0:76dfa9657d9d | 183 | ble_hids_feature_rep_init_t * p_feature_rep_array; /**< Information about the Feature Report characteristics. */ |
jksoft | 0:76dfa9657d9d | 184 | ble_hids_rep_map_init_t rep_map; /**< Information nedeed for initialization of the Report Map characteristic. */ |
jksoft | 0:76dfa9657d9d | 185 | ble_hids_hid_information_t hid_information; /**< Value of the HID Information characteristic. */ |
jksoft | 0:76dfa9657d9d | 186 | uint8_t included_services_count; /**< Number of services to include in HID service. */ |
jksoft | 0:76dfa9657d9d | 187 | uint16_t * p_included_services_array; /**< Array of services to include in HID service. */ |
jksoft | 0:76dfa9657d9d | 188 | ble_srv_security_mode_t security_mode_protocol; /**< Security settings for HID service protocol attribute */ |
jksoft | 0:76dfa9657d9d | 189 | ble_srv_security_mode_t security_mode_ctrl_point; /**< Security settings for HID service Control Point attribute */ |
jksoft | 0:76dfa9657d9d | 190 | ble_srv_cccd_security_mode_t security_mode_boot_mouse_inp_rep; /**< Security settings for HID service Mouse input report attribute */ |
jksoft | 0:76dfa9657d9d | 191 | ble_srv_cccd_security_mode_t security_mode_boot_kb_inp_rep; /**< Security settings for HID service Keyboard input report attribute */ |
jksoft | 0:76dfa9657d9d | 192 | ble_srv_security_mode_t security_mode_boot_kb_outp_rep; /**< Security settings for HID service Keyboard output report attribute */ |
jksoft | 0:76dfa9657d9d | 193 | } ble_hids_init_t; |
jksoft | 0:76dfa9657d9d | 194 | |
jksoft | 0:76dfa9657d9d | 195 | /**@brief HID Service structure. This contains various status information for the service. */ |
jksoft | 0:76dfa9657d9d | 196 | typedef struct ble_hids_s |
jksoft | 0:76dfa9657d9d | 197 | { |
jksoft | 0:76dfa9657d9d | 198 | ble_hids_evt_handler_t evt_handler; /**< Event handler to be called for handling events in the HID Service. */ |
jksoft | 0:76dfa9657d9d | 199 | ble_srv_error_handler_t error_handler; /**< Function to be called in case of an error. */ |
jksoft | 0:76dfa9657d9d | 200 | uint16_t service_handle; /**< Handle of HID Service (as provided by the BLE stack). */ |
jksoft | 0:76dfa9657d9d | 201 | ble_gatts_char_handles_t protocol_mode_handles; /**< Handles related to the Protocol Mode characteristic (will only be created if ble_hids_init_t.is_kb or ble_hids_init_t.is_mouse is set). */ |
jksoft | 0:76dfa9657d9d | 202 | uint8_t inp_rep_count; /**< Number of Input Report characteristics. */ |
jksoft | 0:76dfa9657d9d | 203 | ble_hids_rep_char_t inp_rep_array[BLE_HIDS_MAX_INPUT_REP]; /**< Information about the Input Report characteristics. */ |
jksoft | 0:76dfa9657d9d | 204 | uint8_t outp_rep_count; /**< Number of Output Report characteristics. */ |
jksoft | 0:76dfa9657d9d | 205 | ble_hids_rep_char_t outp_rep_array[BLE_HIDS_MAX_OUTPUT_REP]; /**< Information about the Output Report characteristics. */ |
jksoft | 0:76dfa9657d9d | 206 | uint8_t feature_rep_count; /**< Number of Feature Report characteristics. */ |
jksoft | 0:76dfa9657d9d | 207 | ble_hids_rep_char_t feature_rep_array[BLE_HIDS_MAX_FEATURE_REP]; /**< Information about the Feature Report characteristics. */ |
jksoft | 0:76dfa9657d9d | 208 | ble_gatts_char_handles_t rep_map_handles; /**< Handles related to the Report Map characteristic. */ |
jksoft | 0:76dfa9657d9d | 209 | uint16_t rep_map_ext_rep_ref_handle; /**< Handle of the Report Map External Report Reference descriptor. */ |
jksoft | 0:76dfa9657d9d | 210 | ble_gatts_char_handles_t boot_kb_inp_rep_handles; /**< Handles related to the Boot Keyboard Input Report characteristic (will only be created if ble_hids_init_t.is_kb is set). */ |
jksoft | 0:76dfa9657d9d | 211 | ble_gatts_char_handles_t boot_kb_outp_rep_handles; /**< Handles related to the Boot Keyboard Output Report characteristic (will only be created if ble_hids_init_t.is_kb is set). */ |
jksoft | 0:76dfa9657d9d | 212 | ble_gatts_char_handles_t boot_mouse_inp_rep_handles; /**< Handles related to the Boot Mouse Input Report characteristic (will only be created if ble_hids_init_t.is_mouse is set). */ |
jksoft | 0:76dfa9657d9d | 213 | ble_gatts_char_handles_t hid_information_handles; /**< Handles related to the Report Map characteristic. */ |
jksoft | 0:76dfa9657d9d | 214 | ble_gatts_char_handles_t hid_control_point_handles; /**< Handles related to the Report Map characteristic. */ |
jksoft | 0:76dfa9657d9d | 215 | uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack, is BLE_CONN_HANDLE_INVALID if not in a connection). */ |
jksoft | 0:76dfa9657d9d | 216 | } ble_hids_t; |
jksoft | 0:76dfa9657d9d | 217 | |
jksoft | 0:76dfa9657d9d | 218 | /**@brief Function for initializing the HID Service. |
jksoft | 0:76dfa9657d9d | 219 | * |
jksoft | 0:76dfa9657d9d | 220 | * @param[out] p_hids HID Service structure. This structure will have to be supplied by the |
jksoft | 0:76dfa9657d9d | 221 | * application. It will be initialized by this function, and will later be |
jksoft | 0:76dfa9657d9d | 222 | * used to identify this particular service instance. |
jksoft | 0:76dfa9657d9d | 223 | * @param[in] p_hids_init Information needed to initialize the service. |
jksoft | 0:76dfa9657d9d | 224 | * |
jksoft | 0:76dfa9657d9d | 225 | * @return NRF_SUCCESS on successful initialization of service, otherwise an error code. |
jksoft | 0:76dfa9657d9d | 226 | */ |
jksoft | 0:76dfa9657d9d | 227 | uint32_t ble_hids_init(ble_hids_t * p_hids, const ble_hids_init_t * p_hids_init); |
jksoft | 0:76dfa9657d9d | 228 | |
jksoft | 0:76dfa9657d9d | 229 | /**@brief Function for handling the Application's BLE Stack events. |
jksoft | 0:76dfa9657d9d | 230 | * |
jksoft | 0:76dfa9657d9d | 231 | * @details Handles all events from the BLE stack of interest to the HID Service. |
jksoft | 0:76dfa9657d9d | 232 | * |
jksoft | 0:76dfa9657d9d | 233 | * @param[in] p_hids HID Service structure. |
jksoft | 0:76dfa9657d9d | 234 | * @param[in] p_ble_evt Event received from the BLE stack. |
jksoft | 0:76dfa9657d9d | 235 | */ |
jksoft | 0:76dfa9657d9d | 236 | void ble_hids_on_ble_evt(ble_hids_t * p_hids, ble_evt_t * p_ble_evt); |
jksoft | 0:76dfa9657d9d | 237 | |
jksoft | 0:76dfa9657d9d | 238 | /**@brief Function for sending Input Report. |
jksoft | 0:76dfa9657d9d | 239 | * |
jksoft | 0:76dfa9657d9d | 240 | * @details Sends data on an Input Report characteristic. |
jksoft | 0:76dfa9657d9d | 241 | * |
jksoft | 0:76dfa9657d9d | 242 | * @param[in] p_hids HID Service structure. |
jksoft | 0:76dfa9657d9d | 243 | * @param[in] rep_index Index of the characteristic (corresponding to the index in |
jksoft | 0:76dfa9657d9d | 244 | * ble_hids_t.inp_rep_array as passed to ble_hids_init()). |
jksoft | 0:76dfa9657d9d | 245 | * @param[in] len Length of data to be sent. |
jksoft | 0:76dfa9657d9d | 246 | * @param[in] p_data Pointer to data to be sent. |
jksoft | 0:76dfa9657d9d | 247 | * |
jksoft | 0:76dfa9657d9d | 248 | * @return NRF_SUCCESS on successful sending of input report, otherwise an error code. |
jksoft | 0:76dfa9657d9d | 249 | */ |
jksoft | 0:76dfa9657d9d | 250 | uint32_t ble_hids_inp_rep_send(ble_hids_t * p_hids, |
jksoft | 0:76dfa9657d9d | 251 | uint8_t rep_index, |
jksoft | 0:76dfa9657d9d | 252 | uint16_t len, |
jksoft | 0:76dfa9657d9d | 253 | uint8_t * p_data); |
jksoft | 0:76dfa9657d9d | 254 | |
jksoft | 0:76dfa9657d9d | 255 | /**@brief Function for sending Boot Keyboard Input Report. |
jksoft | 0:76dfa9657d9d | 256 | * |
jksoft | 0:76dfa9657d9d | 257 | * @details Sends data on an Boot Keyboard Input Report characteristic. |
jksoft | 0:76dfa9657d9d | 258 | * |
jksoft | 0:76dfa9657d9d | 259 | * @param[in] p_hids HID Service structure. |
jksoft | 0:76dfa9657d9d | 260 | * @param[in] len Length of data to be sent. |
jksoft | 0:76dfa9657d9d | 261 | * @param[in] p_data Pointer to data to be sent. |
jksoft | 0:76dfa9657d9d | 262 | * |
jksoft | 0:76dfa9657d9d | 263 | * @return NRF_SUCCESS on successful sending of the report, otherwise an error code. |
jksoft | 0:76dfa9657d9d | 264 | */ |
jksoft | 0:76dfa9657d9d | 265 | uint32_t ble_hids_boot_kb_inp_rep_send(ble_hids_t * p_hids, |
jksoft | 0:76dfa9657d9d | 266 | uint16_t len, |
jksoft | 0:76dfa9657d9d | 267 | uint8_t * p_data); |
jksoft | 0:76dfa9657d9d | 268 | |
jksoft | 0:76dfa9657d9d | 269 | /**@brief Function for sending Boot Mouse Input Report. |
jksoft | 0:76dfa9657d9d | 270 | * |
jksoft | 0:76dfa9657d9d | 271 | * @details Sends data on an Boot Mouse Input Report characteristic. |
jksoft | 0:76dfa9657d9d | 272 | * |
jksoft | 0:76dfa9657d9d | 273 | * @param[in] p_hids HID Service structure. |
jksoft | 0:76dfa9657d9d | 274 | * @param[in] buttons State of mouse buttons. |
jksoft | 0:76dfa9657d9d | 275 | * @param[in] x_delta Horizontal movement. |
jksoft | 0:76dfa9657d9d | 276 | * @param[in] y_delta Vertical movement. |
jksoft | 0:76dfa9657d9d | 277 | * @param[in] optional_data_len Length of optional part of Boot Mouse Input Report. |
jksoft | 0:76dfa9657d9d | 278 | * @param[in] p_optional_data Optional part of Boot Mouse Input Report. |
jksoft | 0:76dfa9657d9d | 279 | * |
jksoft | 0:76dfa9657d9d | 280 | * @return NRF_SUCCESS on successful sending of the report, otherwise an error code. |
jksoft | 0:76dfa9657d9d | 281 | */ |
jksoft | 0:76dfa9657d9d | 282 | uint32_t ble_hids_boot_mouse_inp_rep_send(ble_hids_t * p_hids, |
jksoft | 0:76dfa9657d9d | 283 | uint8_t buttons, |
jksoft | 0:76dfa9657d9d | 284 | int8_t x_delta, |
jksoft | 0:76dfa9657d9d | 285 | int8_t y_delta, |
jksoft | 0:76dfa9657d9d | 286 | uint16_t optional_data_len, |
jksoft | 0:76dfa9657d9d | 287 | uint8_t * p_optional_data); |
jksoft | 0:76dfa9657d9d | 288 | |
jksoft | 0:76dfa9657d9d | 289 | /**@brief Function for getting the current value of Output Report from the stack. |
jksoft | 0:76dfa9657d9d | 290 | * |
jksoft | 0:76dfa9657d9d | 291 | * @details Fetches the current value of the output report characteristic from the stack. |
jksoft | 0:76dfa9657d9d | 292 | * |
jksoft | 0:76dfa9657d9d | 293 | * @param[in] p_hids HID Service structure. |
jksoft | 0:76dfa9657d9d | 294 | * @param[in] rep_index Index of the characteristic (corresponding to the index in |
jksoft | 0:76dfa9657d9d | 295 | * ble_hids_t.outp_rep_array as passed to ble_hids_init()). |
jksoft | 0:76dfa9657d9d | 296 | * @param[in] len Length of output report needed. |
jksoft | 0:76dfa9657d9d | 297 | * @param[in] offset Offset in bytes to read from. |
jksoft | 0:76dfa9657d9d | 298 | * @param[out] p_outp_rep Pointer to the output report. |
jksoft | 0:76dfa9657d9d | 299 | * |
jksoft | 0:76dfa9657d9d | 300 | * @return NRF_SUCCESS on successful read of the report, otherwise an error code. |
jksoft | 0:76dfa9657d9d | 301 | */ |
jksoft | 0:76dfa9657d9d | 302 | uint32_t ble_hids_outp_rep_get(ble_hids_t * p_hids, |
jksoft | 0:76dfa9657d9d | 303 | uint8_t rep_index, |
jksoft | 0:76dfa9657d9d | 304 | uint16_t len, |
jksoft | 0:76dfa9657d9d | 305 | uint8_t offset, |
jksoft | 0:76dfa9657d9d | 306 | uint8_t * p_outp_rep); |
jksoft | 0:76dfa9657d9d | 307 | |
jksoft | 0:76dfa9657d9d | 308 | #endif // BLE_HIDS_H__ |
jksoft | 0:76dfa9657d9d | 309 | |
jksoft | 0:76dfa9657d9d | 310 | /** @} */ |