hids.h
Go to the documentation of this file.
1
66 #ifndef __HIDS_H__
67 #define __HIDS_H__
68
69 #include "ble_prf_utils.h"
70 #include "gr55xx_sys.h"
71 #include "custom_config.h"
72 #include <stdint.h>
73
79 #define HIDS_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
80 10 : CFG_MAX_CONNECTIONS)
82 #define HIDS_REPORT_MAX_SIZE 20
83 #define HIDS_REPORT_MAP_MAX_SIZE 512
90 #define HIDS_REP_TYPE_INPUT 1
91 #define HIDS_REP_TYPE_OUTPUT 2
92 #define HIDS_REP_TYPE_FEATURE 3
100 #define HID_INFO_FLAG_REMOTE_WAKE_MSK 0x01
101 #define HID_INFO_FLAG_NORMALLY_CONNECTABLE_MSK 0x02
112 typedef enum
113 {
114 HIDS_EVT_INVALID,
115 HIDS_EVT_IN_REP_NOTIFY_ENABLED,
116 HIDS_EVT_IN_REP_NOTIFY_DISABLED,
117 HIDS_EVT_HOST_SUSP,
118 HIDS_EVT_HOST_EXIT_SUSP,
119 HIDS_EVT_BOOT_MODE_ENTERED,
120 HIDS_EVT_REPORT_MODE_ENTERED,
121 HIDS_EVT_REP_CHAR_WRITE,
122 } hids_evt_type_t;
123
124
126 typedef enum
127 {
128 HIDS_REPORT_TYPE_RESERVED,
129 HIDS_REPORT_TYPE_IN1,
130 HIDS_REPORT_TYPE_IN2,
131 HIDS_REPORT_TYPE_IN3,
132 HIDS_REPORT_TYPE_OUT,
133 HIDS_REPORT_TYPE_FEATURE,
134 HIDS_REPORT_TYPE_KB_IN,
135 HIDS_REPORT_TYPE_KB_OUT,
136 HIDS_REPORT_TYPE_MOUSE_IN,
137 } hids_report_type_t;
147 typedef struct
148 {
149 hids_evt_type_t evt_type;
150 uint8_t conn_idx;
151 hids_report_type_t report_type;
152 uint16_t offset;
153 uint16_t len;
154 uint8_t const * data;
155 }hids_evt_t;
156
158 typedef struct
159 {
160 uint16_t bcd_hid;
161 uint8_t b_country_code;
162 uint8_t flags;
163 }hids_hid_info_t;
164
165
171 typedef struct
172 {
173 uint8_t report_id;
174 uint8_t report_type;
175 } hids_report_ref_t;
176
177
179 typedef struct
180 {
181 uint16_t value_len;
182 hids_report_ref_t ref;
183 } hids_report_int_t;
184
185
187 typedef struct
188 {
189 uint8_t *p_map;
190 uint16_t len;
191 } hids_report_map_t;
192
193
198 typedef void (*hids_evt_handler_t)(hids_evt_t *p_evt);
199
200
202 typedef struct
203 {
204 hids_evt_handler_t evt_handler;
205 bool is_kb;
206 bool is_mouse;
207 hids_hid_info_t hid_info;
208 hids_report_map_t report_map;
209 uint8_t input_report_count;
210 hids_report_int_t input_report_array[3];
211 bool out_report_sup;
212 hids_report_int_t output_report;
213 bool feature_report_sup;
214 hids_report_int_t feature_report;
215 } hids_init_t;
232 sdk_err_t hids_service_init(hids_init_t *p_hids_init);
233
246 sdk_err_t hids_input_rep_send(uint8_t conn_idx, uint8_t rep_idx, uint8_t *p_data, uint16_t length);
247
259 sdk_err_t hids_boot_kb_in_rep_send(uint8_t conn_idx, uint8_t *p_data, uint16_t length);
260
272 sdk_err_t hids_boot_mouse_in_rep_send(uint8_t conn_idx, uint8_t *p_data, uint16_t length);
275 #endif
276
HIDS_EVT_REP_CHAR_WRITE
@ HIDS_EVT_REP_CHAR_WRITE
Definition: hids.h:121
hids_report_type_t
hids_report_type_t
HID Service write report type.
Definition: hids.h:127
hids_init_t::is_kb
bool is_kb
Definition: hids.h:205
hids_init_t::feature_report
hids_report_int_t feature_report
Definition: hids.h:214
hids_hid_info_t::bcd_hid
uint16_t bcd_hid
Definition: hids.h:160
HIDS_REPORT_TYPE_KB_IN
@ HIDS_REPORT_TYPE_KB_IN
Definition: hids.h:134
HIDS_REPORT_TYPE_IN2
@ HIDS_REPORT_TYPE_IN2
Definition: hids.h:130
hids_evt_t::conn_idx
uint8_t conn_idx
Definition: hids.h:150
HIDS_EVT_REPORT_MODE_ENTERED
@ HIDS_EVT_REPORT_MODE_ENTERED
Definition: hids.h:120
HIDS_EVT_IN_REP_NOTIFY_ENABLED
@ HIDS_EVT_IN_REP_NOTIFY_ENABLED
Definition: hids.h:115
HIDS_REPORT_TYPE_IN1
@ HIDS_REPORT_TYPE_IN1
Definition: hids.h:129
HIDS_EVT_HOST_EXIT_SUSP
@ HIDS_EVT_HOST_EXIT_SUSP
Definition: hids.h:118
hids_report_int_t
HID Service Report characteristic define.
Definition: hids.h:180
hids_report_ref_t::report_type
uint8_t report_type
Definition: hids.h:174
HIDS_EVT_HOST_SUSP
@ HIDS_EVT_HOST_SUSP
Definition: hids.h:117
hids_service_init
sdk_err_t hids_service_init(hids_init_t *p_hids_init)
Initialize a HID Service instance in ATT DB.
hids_init_t::out_report_sup
bool out_report_sup
Definition: hids.h:211
hids_init_t::evt_handler
hids_evt_handler_t evt_handler
Definition: hids.h:204
HIDS_REPORT_TYPE_RESERVED
@ HIDS_REPORT_TYPE_RESERVED
Definition: hids.h:128
gr55xx_sys.h
GR55XX System API.
hids_hid_info_t
HID Information characteristic value.
Definition: hids.h:159
hids_report_int_t::value_len
uint16_t value_len
Definition: hids.h:181
HIDS_EVT_IN_REP_NOTIFY_DISABLED
@ HIDS_EVT_IN_REP_NOTIFY_DISABLED
Definition: hids.h:116
hids_report_map_t::len
uint16_t len
Definition: hids.h:190
hids_evt_t::len
uint16_t len
Definition: hids.h:153
HIDS_EVT_INVALID
@ HIDS_EVT_INVALID
Definition: hids.h:114
hids_evt_t::evt_type
hids_evt_type_t evt_type
Definition: hids.h:149
hids_init_t::feature_report_sup
bool feature_report_sup
Definition: hids.h:213
hids_evt_handler_t
void(* hids_evt_handler_t)(hids_evt_t *p_evt)
HID Service event handler type.
Definition: hids.h:198
hids_input_rep_send
sdk_err_t hids_input_rep_send(uint8_t conn_idx, uint8_t rep_idx, uint8_t *p_data, uint16_t length)
Send an input report.
hids_evt_t::offset
uint16_t offset
Definition: hids.h:152
hids_evt_type_t
hids_evt_type_t
HID Service event type.
Definition: hids.h:113
hids_report_map_t
HID Service Report Map characteristic value.
Definition: hids.h:188
hids_report_ref_t
Value of a Report Reference descriptor.
Definition: hids.h:172
hids_init_t::output_report
hids_report_int_t output_report
Definition: hids.h:212
hids_init_t::is_mouse
bool is_mouse
Definition: hids.h:206
hids_init_t::report_map
hids_report_map_t report_map
Definition: hids.h:208
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
hids_hid_info_t::flags
uint8_t flags
Definition: hids.h:162
hids_report_ref_t::report_id
uint8_t report_id
Definition: hids.h:173
HIDS_EVT_BOOT_MODE_ENTERED
@ HIDS_EVT_BOOT_MODE_ENTERED
Definition: hids.h:119
HIDS_REPORT_TYPE_MOUSE_IN
@ HIDS_REPORT_TYPE_MOUSE_IN
Definition: hids.h:136
hids_report_int_t::ref
hids_report_ref_t ref
Definition: hids.h:182
HIDS_REPORT_TYPE_KB_OUT
@ HIDS_REPORT_TYPE_KB_OUT
Definition: hids.h:135
hids_evt_t::data
uint8_t const * data
Definition: hids.h:154
hids_evt_t
HID Service event.
Definition: hids.h:148
HIDS_REPORT_TYPE_OUT
@ HIDS_REPORT_TYPE_OUT
Definition: hids.h:132
hids_report_map_t::p_map
uint8_t * p_map
Definition: hids.h:189
ble_prf_utils.h
Profile/Service Utilities API.
HIDS_REPORT_TYPE_IN3
@ HIDS_REPORT_TYPE_IN3
Definition: hids.h:131
hids_evt_t::report_type
hids_report_type_t report_type
Definition: hids.h:151
hids_boot_mouse_in_rep_send
sdk_err_t hids_boot_mouse_in_rep_send(uint8_t conn_idx, uint8_t *p_data, uint16_t length)
Send boot mouse input report.
HIDS_REPORT_TYPE_FEATURE
@ HIDS_REPORT_TYPE_FEATURE
Definition: hids.h:133
hids_hid_info_t::b_country_code
uint8_t b_country_code
Definition: hids.h:161
hids_init_t
HID Service initialization variable.
Definition: hids.h:203
hids_init_t::hid_info
hids_hid_info_t hid_info
Definition: hids.h:207
hids_init_t::input_report_count
uint8_t input_report_count
Definition: hids.h:209
hids_boot_kb_in_rep_send
sdk_err_t hids_boot_kb_in_rep_send(uint8_t conn_idx, uint8_t *p_data, uint16_t length)
Send boot keyboard input report.