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