55 #include "hci_event.h"
57 extern uint8 hciTaskID;
59 extern uint8 hciTestTaskID;
60 extern uint8 hciGapTaskID;
61 extern uint8 hciL2capTaskID;
62 extern uint8 hciSmpTaskID;
68 #define HCI_ASSERT(condition) HAL_ASSERT(condition)
82 #define HCI_TX_PROCESS_EVENT 0x0001
83 #define HCI_TEST_UART_SEND_EVENT 0x0002
84 #define HCI_ADV_NOTICE_EVENT 0x0004
85 #define HCI_SCAN_NOTICE_EVENT 0x0008
86 #define HCI_CONN_NOTICE_EVENT 0x0010
87 #define HCI_BDADDR_UPDATED_EVENT 0x4000
90 #define HCI_CTRL_TO_HOST_EVENT 0x01
91 #define HCI_HOST_TO_CTRL_CMD_EVENT 0x02
92 #define HCI_HOST_TO_CTRL_DATA_EVENT 0x03
94 #define HCI_BDADDR_LEN 6
97 #define HCI_MAX_CMD_PKT_SIZE 0xFF
98 #define HCI_MAX_DATA_PKT_SIZE 0xFFFF
101 #define HCI_DATA_MAX_DATA_LENGTH 27
107 #define HCI_CMD_MIN_LENGTH 4
113 #define HCI_EVENT_MIN_LENGTH 3
119 #define HCI_DATA_MIN_LENGTH 5
122 #define HCI_MAX_NUM_CONNECTIONS 0x03
124 #define HCI_TX_DATA_ANY_CONNECTION 0xFF
127 #define HCI_CMD_PACKET 0x01
128 #define HCI_ACL_DATA_PACKET 0x02
129 #define HCI_SCO_DATA_PACKET 0x03
130 #define HCI_EVENT_PACKET 0x04
134 #define HCI_PARSER_STATE_PKT_TYPE 0
136 #define HCI_CMD_PARSER_STATE_OPCODE 1
137 #define HCI_CMD_PARSER_STATE_LENGTH 2
138 #define HCI_CMD_PARSER_STATE_DATA 3
140 #define HCI_DATA_PARSER_STATE_HANDLE 4
141 #define HCI_DATA_PARSER_STATE_LENGTH 5
142 #define HCI_DATA_PARSER_STATE_DATA 6
145 #define HCI_OPCODE_CSG_LINK_LAYER 0
146 #define HCI_OPCODE_CSG_CSG_L2CAP 1
147 #define HCI_OPCODE_CSG_CSG_ATT 2
148 #define HCI_OPCODE_CSG_CSG_GATT 3
149 #define HCI_OPCODE_CSG_CSG_GAP 4
150 #define HCI_OPCODE_CSG_CSG_SM 5
151 #define HCI_OPCODE_CSG_CSG_Reserved 6
152 #define HCI_OPCODE_CSG_CSG_USER_PROFILE 7
155 #define VENDOR_SPECIFIC_OGF 0x3F
162 #define HCI_DISCONNECT 0x0406
163 #define HCI_READ_REMOTE_VERSION_INFO 0x041D
166 #define HCI_SET_EVENT_MASK 0x0C01
167 #define HCI_RESET 0x0C03
168 #define HCI_READ_TRANSMIT_POWER 0x0C2D
169 #define HCI_SET_CONTROLLER_TO_HOST_FLOW_CONTROL 0x0C31
170 #define HCI_HOST_BUFFER_SIZE 0x0C33
171 #define HCI_HOST_NUM_COMPLETED_PACKETS 0x0C35
172 #define HCI_SET_EVENT_MASK_PAGE_2 0x0C63
173 #define HCI_READ_AUTH_PAYLOAD_TIMEOUT 0x0C7B
174 #define HCI_WRITE_AUTH_PAYLOAD_TIMEOUT 0x0C7C
177 #define HCI_READ_LOCAL_VERSION_INFO 0x1001
178 #define HCI_READ_LOCAL_SUPPORTED_COMMANDS 0x1002
179 #define HCI_READ_LOCAL_SUPPORTED_FEATURES 0x1003
180 #define HCI_READ_BDADDR 0x1009
183 #define HCI_READ_RSSI 0x1405
187 #define HCI_LE_SET_EVENT_MASK 0x2001
188 #define HCI_LE_READ_BUFFER_SIZE 0x2002
189 #define HCI_LE_READ_LOCAL_SUPPORTED_FEATURES 0x2003
190 #define HCI_LE_SET_RANDOM_ADDR 0x2005
191 #define HCI_LE_SET_ADV_PARAM 0x2006
192 #define HCI_LE_READ_ADV_CHANNEL_TX_POWER 0x2007
193 #define HCI_LE_SET_ADV_DATA 0x2008
194 #define HCI_LE_SET_SCAN_RSP_DATA 0x2009
195 #define HCI_LE_SET_ADV_ENABLE 0x200A
196 #define HCI_LE_SET_SCAN_PARAM 0x200B
197 #define HCI_LE_SET_SCAN_ENABLE 0x200C
198 #define HCI_LE_CREATE_CONNECTION 0x200D
199 #define HCI_LE_CREATE_CONNECTION_CANCEL 0x200E
200 #define HCI_LE_READ_WHITE_LIST_SIZE 0x200F
201 #define HCI_LE_CLEAR_WHITE_LIST 0x2010
202 #define HCI_LE_ADD_WHITE_LIST 0x2011
203 #define HCI_LE_REMOVE_WHITE_LIST 0x2012
204 #define HCI_LE_CONNECTION_UPDATE 0x2013
205 #define HCI_LE_SET_HOST_CHANNEL_CLASSIFICATION 0x2014
206 #define HCI_LE_READ_CHANNEL_MAP 0x2015
207 #define HCI_LE_READ_REMOTE_USED_FEATURES 0x2016
208 #define HCI_LE_ENCRYPT 0x2017
209 #define HCI_LE_RAND 0x2018
210 #define HCI_LE_START_ENCRYPTION 0x2019
211 #define HCI_LE_LTK_REQ_REPLY 0x201A
212 #define HCI_LE_LTK_REQ_NEG_REPLY 0x201B
213 #define HCI_LE_READ_SUPPORTED_STATES 0x201C
214 #define HCI_LE_RECEIVER_TEST 0x201D
215 #define HCI_LE_TRANSMITTER_TEST 0x201E
216 #define HCI_LE_TEST_END 0x201F
218 #define HCI_LE_REMOTE_CONN_PARAM_REQ_REPLY 0x2020
219 #define HCI_LE_REMOTE_CONN_PARAM_REQ_NEG_REPLY 0x2021
221 #define HCI_LE_SET_DATA_LENGTH 0x2022
222 #define HCI_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH 0x2023
223 #define HCI_LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH 0x2024
224 #define HCI_LE_READ_LOCAL_P256_PUBLIC_KEY 0x2025
225 #define HCI_LE_GENERATE_DHKEY 0x2026
226 #define HCI_LE_ADD_DEVICE_TO_RESOLVING_LIST 0x2027
227 #define HCI_LE_REMOVE_DEVICE_FROM_RESOLVING_LIST 0x2028
228 #define HCI_LE_CLEAR_RESOLVING_LIST 0x2029
229 #define HCI_LE_READ_RESOLVING_LIST_SIZE 0x202A
230 #define HCI_LE_READ_PEER_RESOLVABLE_ADDRESS 0x202B
231 #define HCI_LE_READ_LOCAL_RESOLVABLE_ADDRESS 0x202C
232 #define HCI_LE_SET_ADDRESS_RESOLUTION_ENABLE 0x202D
233 #define HCI_LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT 0x202E
234 #define HCI_LE_READ_MAX_DATA_LENGTH 0x202F
236 #define HCI_LE_READ_PHY 0x2030
237 #define HCI_LE_SET_DEFAULT_PHY 0x2031
238 #define HCI_LE_SET_PHY 0x2032
239 #define HCI_LE_ENHANCED_RECEIVER_TEST 0x2033
240 #define HCI_LE_ENHANCED_TRANSMITTER_TEST 0x2034
243 #define HCI_EXT_SET_RX_GAIN 0xFC00
244 #define HCI_EXT_SET_TX_POWER 0xFC01
245 #define HCI_EXT_ONE_PKT_PER_EVT 0xFC02
246 #define HCI_EXT_CLK_DIVIDE_ON_HALT 0xFC03
247 #define HCI_EXT_DECLARE_NV_USAGE 0xFC04
248 #define HCI_EXT_DECRYPT 0xFC05
249 #define HCI_EXT_SET_LOCAL_SUPPORTED_FEATURES 0xFC06
250 #define HCI_EXT_SET_FAST_TX_RESP_TIME 0xFC07
251 #define HCI_EXT_MODEM_TEST_TX 0xFC08
252 #define HCI_EXT_MODEM_HOP_TEST_TX 0xFC09
253 #define HCI_EXT_MODEM_TEST_RX 0xFC0A
254 #define HCI_EXT_END_MODEM_TEST 0xFC0B
255 #define HCI_EXT_SET_BDADDR 0xFC0C
256 #define HCI_EXT_SET_SCA 0xFC0D
257 #define HCI_EXT_ENABLE_PTM 0xFC0E // Not a supported HCI command! Application only.
258 #define HCI_EXT_SET_FREQ_TUNE 0xFC0F
259 #define HCI_EXT_SAVE_FREQ_TUNE 0xFC10
260 #define HCI_EXT_SET_MAX_DTM_TX_POWER 0xFC11
261 #define HCI_EXT_MAP_PM_IO_PORT 0xFC12
262 #define HCI_EXT_DISCONNECT_IMMED 0xFC13
263 #define HCI_EXT_PER 0xFC14
264 #define HCI_EXT_PER_BY_CHAN 0xFC15 // Not a supported HCI command! Application only.
265 #define HCI_EXT_EXTEND_RF_RANGE 0xFC16
266 #define HCI_EXT_ADV_EVENT_NOTICE 0xFC17 // Not a supported HCI command! Application only.
267 #define HCI_EXT_CONN_EVENT_NOTICE 0xFC18 // Not a supported HCI command! Application only.
268 #define HCI_EXT_HALT_DURING_RF 0xFC19
269 #define HCI_EXT_OVERRIDE_SL 0xFC1A
270 #define HCI_EXT_BUILD_REVISION 0xFC1B
271 #define HCI_EXT_DELAY_SLEEP 0xFC1C
272 #define HCI_EXT_RESET_SYSTEM 0xFC1D
273 #define HCI_EXT_OVERLAPPED_PROCESSING 0xFC1E
274 #define HCI_EXT_NUM_COMPLETED_PKTS_LIMIT 0xFC1F
275 #define HCI_EXT_GET_CONNECTION_INFO 0xFC20
276 #define HCI_EXT_SET_MAX_DATA_LENGTH 0xFC21
277 #define HCI_EXT_SCAN_EVENT_NOTICE 0xFC22 // Not a supported HCI command! Application only.
278 #define HCI_EXT_SCAN_REQ_REPORT 0xFC23
280 #define HCI_EXT_LL_TEST_MODE 0xFC70
287 #define HCI_DISCONNECTION_COMPLETE_EVENT_CODE 0x05
288 #define HCI_ENCRYPTION_CHANGE_EVENT_CODE 0x08
289 #define HCI_READ_REMOTE_INFO_COMPLETE_EVENT_CODE 0x0C
290 #define HCI_COMMAND_COMPLETE_EVENT_CODE 0x0E
291 #define HCI_COMMAND_STATUS_EVENT_CODE 0x0F
292 #define HCI_BLE_HARDWARE_ERROR_EVENT_CODE 0x10
293 #define HCI_NUM_OF_COMPLETED_PACKETS_EVENT_CODE 0x13
294 #define HCI_DATA_BUFFER_OVERFLOW_EVENT 0x1A
295 #define HCI_KEY_REFRESH_COMPLETE_EVENT_CODE 0x30
296 #define HCI_APTO_EXPIRED_EVENT_CODE 0x57
299 #define HCI_LE_EVENT_CODE 0x3E
302 #define HCI_BLE_CONNECTION_COMPLETE_EVENT 0x01
303 #define HCI_BLE_ADV_REPORT_EVENT 0x02
304 #define HCI_BLE_CONN_UPDATE_COMPLETE_EVENT 0x03
305 #define HCI_BLE_READ_REMOTE_FEATURE_COMPLETE_EVENT 0x04
306 #define HCI_BLE_LTK_REQUESTED_EVENT 0x05
308 #define HCI_BLE_REMOTE_CONN_PARAM_REQUEST_EVENT 0x06
310 #define HCI_BLE_DATA_LENGTH_CHANGE_EVENT 0x07
311 #define HCI_BLE_READ_LOCAL_P256_PUBLIC_KEY_COMPLETE_EVENT 0x08
312 #define HCI_BLE_GENERATE_DHKEY_COMPLETE_EVENT 0x09
313 #define HCI_BLE_ENHANCED_CONNECTION_COMPLETE_EVENT 0x0A
314 #define HCI_BLE_DIRECT_ADVERTISING_REPORT_EVENT 0x0B
316 #define HCI_BLE_PHY_UPDATE_COMPLETE_EVENT 0x0C
318 #define HCI_BLE_SCAN_REQ_REPORT_EVENT 0x80
321 #define HCI_VE_EVENT_CODE 0xFF
324 #define HCI_EXT_SET_RX_GAIN_EVENT 0x0400
325 #define HCI_EXT_SET_TX_POWER_EVENT 0x0401
326 #define HCI_EXT_ONE_PKT_PER_EVT_EVENT 0x0402
327 #define HCI_EXT_CLK_DIVIDE_ON_HALT_EVENT 0x0403
328 #define HCI_EXT_DECLARE_NV_USAGE_EVENT 0x0404
329 #define HCI_EXT_DECRYPT_EVENT 0x0405
330 #define HCI_EXT_SET_LOCAL_SUPPORTED_FEATURES_EVENT 0x0406
331 #define HCI_EXT_SET_FAST_TX_RESP_TIME_EVENT 0x0407
332 #define HCI_EXT_MODEM_TEST_TX_EVENT 0x0408
333 #define HCI_EXT_MODEM_HOP_TEST_TX_EVENT 0x0409
334 #define HCI_EXT_MODEM_TEST_RX_EVENT 0x040A
335 #define HCI_EXT_END_MODEM_TEST_EVENT 0x040B
336 #define HCI_EXT_SET_BDADDR_EVENT 0x040C
337 #define HCI_EXT_SET_SCA_EVENT 0x040D
338 #define HCI_EXT_ENABLE_PTM_EVENT 0x040E // Not a supported HCI command! Application only.
339 #define HCI_EXT_SET_FREQ_TUNE_EVENT 0x040F
340 #define HCI_EXT_SAVE_FREQ_TUNE_EVENT 0x0410
341 #define HCI_EXT_SET_MAX_DTM_TX_POWER_EVENT 0x0411
342 #define HCI_EXT_MAP_PM_IO_PORT_EVENT 0x0412
343 #define HCI_EXT_DISCONNECT_IMMED_EVENT 0x0413
344 #define HCI_EXT_PER_EVENT 0x0414
345 #define HCI_EXT_PER_BY_CHAN_EVENT 0x0415 // Not a supported HCI command! Application only.
346 #define HCI_EXT_EXTEND_RF_RANGE_EVENT 0x0416
347 #define HCI_EXT_ADV_EVENT_NOTICE_EVENT 0x0417 // Not a supported HCI command! Application only.
348 #define HCI_EXT_CONN_EVENT_NOTICE_EVENT 0x0418 // Not a supported HCI command! Application only.
349 #define HCI_EXT_HALT_DURING_RF_EVENT 0x0419
350 #define HCI_EXT_OVERRIDE_SL_EVENT 0x041A
351 #define HCI_EXT_BUILD_REVISION_EVENT 0x041B
352 #define HCI_EXT_DELAY_SLEEP_EVENT 0x041C
353 #define HCI_EXT_RESET_SYSTEM_EVENT 0x041D
354 #define HCI_EXT_OVERLAPPED_PROCESSING_EVENT 0x041E
355 #define HCI_EXT_NUM_COMPLETED_PKTS_LIMIT_EVENT 0x041F
356 #define HCI_EXT_GET_CONNECTION_INFO_EVENT 0x0420
357 #define HCI_EXT_SET_MAX_DATA_LENGTH_EVENT 0x0421
358 #define HCI_EXT_SCAN_EVENT_NOTICE_EVENT 0x0422 // Not a supported HCI command! Application only.
359 #define HCI_EXT_SCAN_REQ_REPORT_EVENT 0x0423
361 #define HCI_EXT_LL_TEST_MODE_EVENT 0x0470
397 extern void HCI_Init( uint8 taskID );
416 extern void HCI_TL_getCmdResponderID( uint8 taskID );
435 extern uint16 HCI_ProcessEvent( uint8 task_id,
This API allows the software components in the Z-Stack to be written independently of the specifics o...