xref: /btstack/src/btstack_defines.h (revision 827b1c43e5480ad8fc0321fa9e56fdee431481e0)
1 /*
2  * Copyright (C) 2015 BlueKitchen GmbH
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holders nor the names of
14  *    contributors may be used to endorse or promote products derived
15  *    from this software without specific prior written permission.
16  * 4. Any redistribution, use, or modification is done solely for
17  *    personal benefit and not for any commercial purpose or for
18  *    monetary gain.
19  *
20  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  * Please inquire about commercial licensing options at
34  * [email protected]
35  *
36  */
37 
38 /*
39  * btstack-defines.h
40  *
41  * BTstack definitions, events, and error codes */
42 
43 #ifndef __BTSTACK_DEFINES_H
44 #define __BTSTACK_DEFINES_H
45 
46 #include <stdint.h>
47 #include "btstack_linked_list.h"
48 
49 // TYPES
50 
51 // packet handler
52 typedef void (*btstack_packet_handler_t) (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
53 
54 // packet callback supporting multiple registrations
55 typedef struct {
56     btstack_linked_item_t    item;
57     btstack_packet_handler_t callback;
58 } btstack_packet_callback_registration_t;
59 
60 /**
61  * @brief 128 bit key used with AES128 in Security Manager
62  */
63 typedef uint8_t sm_key_t[16];
64 
65 // DEFINES
66 
67 #define DAEMON_EVENT_PACKET     0x05
68 
69 // L2CAP data
70 #define L2CAP_DATA_PACKET       0x06
71 
72 // RFCOMM data
73 #define RFCOMM_DATA_PACKET      0x07
74 
75 // Attribute protocol data
76 #define ATT_DATA_PACKET         0x08
77 
78 // Security Manager protocol data
79 #define SM_DATA_PACKET          0x09
80 
81 // SDP query result
82 // format: type (8), record_id (16), attribute_id (16), attribute_length (16), attribute_value (max 1k)
83 #define SDP_CLIENT_PACKET       0x0a
84 
85 // BNEP data
86 #define BNEP_DATA_PACKET        0x0b
87 
88 // Unicast Connectionless Data
89 #define UCD_DATA_PACKET         0x0c
90 
91 // debug log messages
92 #define LOG_MESSAGE_PACKET      0xfc
93 
94 
95 // ERRORS
96 
97 // last error code in 2.1 is 0x38 - we start with 0x50 for BTstack errors
98 #define BTSTACK_CONNECTION_TO_BTDAEMON_FAILED              0x50
99 #define BTSTACK_ACTIVATION_FAILED_SYSTEM_BLUETOOTH         0x51
100 #define BTSTACK_ACTIVATION_POWERON_FAILED                  0x52
101 #define BTSTACK_ACTIVATION_FAILED_UNKNOWN                  0x53
102 #define BTSTACK_NOT_ACTIVATED                              0x54
103 #define BTSTACK_BUSY                                       0x55
104 #define BTSTACK_MEMORY_ALLOC_FAILED                        0x56
105 #define BTSTACK_ACL_BUFFERS_FULL                           0x57
106 
107 // l2cap errors - enumeration by the command that created them
108 #define L2CAP_COMMAND_REJECT_REASON_COMMAND_NOT_UNDERSTOOD 0x60
109 #define L2CAP_COMMAND_REJECT_REASON_SIGNALING_MTU_EXCEEDED 0x61
110 #define L2CAP_COMMAND_REJECT_REASON_INVALID_CID_IN_REQUEST 0x62
111 
112 #define L2CAP_CONNECTION_RESPONSE_RESULT_SUCCESSFUL        0x63
113 #define L2CAP_CONNECTION_RESPONSE_RESULT_PENDING           0x64
114 #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_PSM       0x65
115 #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_SECURITY  0x66
116 #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_RESOURCES 0x67
117 #define L2CAP_CONNECTION_RESPONSE_RESULT_RTX_TIMEOUT       0x68
118 
119 #define L2CAP_SERVICE_ALREADY_REGISTERED                   0x69
120 #define L2CAP_DATA_LEN_EXCEEDS_REMOTE_MTU                  0x6A
121 
122 #define RFCOMM_MULTIPLEXER_STOPPED                         0x70
123 #define RFCOMM_CHANNEL_ALREADY_REGISTERED                  0x71
124 #define RFCOMM_NO_OUTGOING_CREDITS                         0x72
125 #define RFCOMM_AGGREGATE_FLOW_OFF                          0x73
126 #define RFCOMM_DATA_LEN_EXCEEDS_MTU                        0x74
127 
128 #define SDP_HANDLE_ALREADY_REGISTERED                      0x80
129 #define SDP_QUERY_INCOMPLETE                               0x81
130 #define SDP_SERVICE_NOT_FOUND                              0x82
131 #define SDP_HANDLE_INVALID                                 0x83
132 #define SDP_QUERY_BUSY                                     0x84
133 
134 #define ATT_HANDLE_VALUE_INDICATION_IN_PORGRESS            0x90
135 #define ATT_HANDLE_VALUE_INDICATION_TIMEOUT                0x91
136 
137 #define GATT_CLIENT_NOT_CONNECTED                          0x93
138 #define GATT_CLIENT_BUSY                                   0x94
139 #define GATT_CLIENT_IN_WRONG_STATE                         0x95
140 #define GATT_CLIENT_DIFFERENT_CONTEXT_FOR_ADDRESS_ALREADY_EXISTS 0x96
141 #define GATT_CLIENT_VALUE_TOO_LONG                         0x97
142 #define GATT_CLIENT_CHARACTERISTIC_NOTIFICATION_NOT_SUPPORTED 0x98
143 #define GATT_CLIENT_CHARACTERISTIC_INDICATION_NOT_SUPPORTED   0x99
144 
145 #define BNEP_SERVICE_ALREADY_REGISTERED                    0xA0
146 #define BNEP_CHANNEL_NOT_CONNECTED                         0xA1
147 #define BNEP_DATA_LEN_EXCEEDS_MTU                          0xA2
148 
149 // COMMANDS
150 
151 #define OGF_BTSTACK 0x3d
152 
153 // cmds for BTstack
154 // get state: @returns HCI_STATE
155 #define BTSTACK_GET_STATE                                  0x01
156 
157 // set power mode: @param HCI_POWER_MODE
158 #define BTSTACK_SET_POWER_MODE                             0x02
159 
160 // set capture mode: @param on
161 #define BTSTACK_SET_ACL_CAPTURE_MODE                       0x03
162 
163 // get BTstack version
164 #define BTSTACK_GET_VERSION                                0x04
165 
166 // get system Bluetooth state
167 #define BTSTACK_GET_SYSTEM_BLUETOOTH_ENABLED               0x05
168 
169 // set system Bluetooth state
170 #define BTSTACK_SET_SYSTEM_BLUETOOTH_ENABLED               0x06
171 
172 // enable inquiry scan for this client
173 #define BTSTACK_SET_DISCOVERABLE                           0x07
174 
175 // set global Bluetooth state
176 #define BTSTACK_SET_BLUETOOTH_ENABLED                      0x08
177 
178 // create l2cap channel: @param bd_addr(48), psm (16)
179 #define L2CAP_CREATE_CHANNEL                               0x20
180 
181 // disconnect l2cap disconnect, @param channel(16), reason(8)
182 #define L2CAP_DISCONNECT                                   0x21
183 
184 // register l2cap service: @param psm(16), mtu (16)
185 #define L2CAP_REGISTER_SERVICE                             0x22
186 
187 // unregister l2cap disconnect, @param psm(16)
188 #define L2CAP_UNREGISTER_SERVICE                           0x23
189 
190 // accept connection @param bd_addr(48), dest cid (16)
191 #define L2CAP_ACCEPT_CONNECTION                            0x24
192 
193 // decline l2cap disconnect,@param bd_addr(48), dest cid (16), reason(8)
194 #define L2CAP_DECLINE_CONNECTION                           0x25
195 
196 // create l2cap channel: @param bd_addr(48), psm (16), mtu (16)
197 #define L2CAP_CREATE_CHANNEL_MTU                           0x26
198 
199 // register SDP Service Record: service record (size)
200 #define SDP_REGISTER_SERVICE_RECORD                        0x30
201 
202 // unregister SDP Service Record
203 #define SDP_UNREGISTER_SERVICE_RECORD                      0x31
204 
205 // Get remote RFCOMM services
206 #define SDP_CLIENT_QUERY_RFCOMM_SERVICES                   0x32
207 
208 // Get remote SDP services
209 #define SDP_CLIENT_QUERY_SERVICES                          0x33
210 
211 // RFCOMM "HCI" Commands
212 #define RFCOMM_CREATE_CHANNEL       0x40
213 #define RFCOMM_DISCONNECT     0x41
214 #define RFCOMM_REGISTER_SERVICE     0x42
215 #define RFCOMM_UNREGISTER_SERVICE   0x43
216 #define RFCOMM_ACCEPT_CONNECTION    0x44
217 #define RFCOMM_DECLINE_CONNECTION   0x45
218 #define RFCOMM_PERSISTENT_CHANNEL   0x46
219 #define RFCOMM_CREATE_CHANNEL_WITH_CREDITS   0x47
220 #define RFCOMM_REGISTER_SERVICE_WITH_CREDITS 0x48
221 #define RFCOMM_GRANT_CREDITS                 0x49
222 
223 // GAP Classic 0x50
224 #define GAP_DISCONNECT              0x50
225 
226 // GAP LE      0x60
227 #define GAP_LE_SCAN_START           0x60
228 #define GAP_LE_SCAN_STOP            0x61
229 #define GAP_LE_CONNECT              0x62
230 #define GAP_LE_CONNECT_CANCEL       0x63
231 #define GAP_LE_SET_SCAN_PARAMETERS  0x64
232 
233 // GATT (Client) 0x70
234 #define GATT_DISCOVER_ALL_PRIMARY_SERVICES                       0x70
235 #define GATT_DISCOVER_PRIMARY_SERVICES_BY_UUID16                 0x71
236 #define GATT_DISCOVER_PRIMARY_SERVICES_BY_UUID128                0x72
237 #define GATT_FIND_INCLUDED_SERVICES_FOR_SERVICE                  0x73
238 #define GATT_DISCOVER_CHARACTERISTICS_FOR_SERVICE                0x74
239 #define GATT_DISCOVER_CHARACTERISTICS_FOR_SERVICE_BY_UUID128     0x75
240 #define GATT_DISCOVER_CHARACTERISTIC_DESCRIPTORS                 0x76
241 #define GATT_READ_VALUE_OF_CHARACTERISTIC                        0x77
242 #define GATT_READ_LONG_VALUE_OF_CHARACTERISTIC                   0x78
243 #define GATT_WRITE_VALUE_OF_CHARACTERISTIC_WITHOUT_RESPONSE      0x79
244 #define GATT_WRITE_VALUE_OF_CHARACTERISTIC                       0x7A
245 #define GATT_WRITE_LONG_VALUE_OF_CHARACTERISTIC                  0x7B
246 #define GATT_RELIABLE_WRITE_LONG_VALUE_OF_CHARACTERISTIC         0x7C
247 #define GATT_READ_CHARACTERISTIC_DESCRIPTOR                      0X7D
248 #define GATT_READ_LONG_CHARACTERISTIC_DESCRIPTOR                 0X7E
249 #define GATT_WRITE_CHARACTERISTIC_DESCRIPTOR                     0X7F
250 #define GATT_WRITE_LONG_CHARACTERISTIC_DESCRIPTOR                0X80
251 #define GATT_WRITE_CLIENT_CHARACTERISTIC_CONFIGURATION           0X81
252 #define GATT_GET_MTU                                             0x82
253 
254 
255 // EVENTS
256 
257 /**
258  * @format 1
259  * @param state
260  */
261 #define BTSTACK_EVENT_STATE                                0x60
262 
263 // data: event(8), len(8), nr hci connections
264 #define BTSTACK_EVENT_NR_CONNECTIONS_CHANGED               0x61
265 
266 /**
267  * @format
268  */
269 #define BTSTACK_EVENT_POWERON_FAILED                       0x62
270 
271 /**
272  * @format 1
273  * @param discoverable
274  */
275 #define BTSTACK_EVENT_DISCOVERABLE_ENABLED                 0x66
276 
277 // Daemon Events
278 
279 /**
280  * @format 112
281  * @param major
282  * @param minor
283  @ @param revision
284  */
285 #define DAEMON_EVENT_VERSION                               0x63
286 
287 // data: system bluetooth on/off (bool)
288 #define DAEMON_EVENT_SYSTEM_BLUETOOTH_ENABLED              0x64
289 
290 // data: event (8), len(8), status (8) == 0, address (48), name (1984 bits = 248 bytes)
291 #define DAEMON_EVENT_REMOTE_NAME_CACHED                    0x65
292 
293 // data: event(8)
294 #define DAEMON_EVENT_CONNECTION_OPENED                     0x68
295 
296 // data: event(8)
297 #define DAEMON_EVENT_CONNECTION_CLOSED                     0x69
298 
299 // data: event(8), nr_connections(8)
300 #define DAEMON_NR_CONNECTIONS_CHANGED                      0x6A
301 
302 // data: event(8)
303 #define DAEMON_EVENT_NEW_RFCOMM_CREDITS                    0x6B
304 
305 // data: event(8)
306 #define DAEMON_EVENT_HCI_PACKET_SENT                       0x6C
307 
308 
309 // additional HCI events
310 /**
311  * @format B
312  * @param handle
313  */
314 #define HCI_EVENT_SCO_CAN_SEND_NOW                         0x6F
315 
316 // L2CAP EVENTS
317 
318 /**
319  * @format 1BH222222
320  * @param status
321  * @param address
322  * @param handle
323  * @param psm
324  * @param local_cid
325  * @param remote_cid
326  * @param local_mtu
327  * @param remote_mtu
328  * @param flush_timeout
329  */
330 #define L2CAP_EVENT_CHANNEL_OPENED                         0x70
331 
332 /*
333  * @format 2
334  * @param local_cid
335  */
336 #define L2CAP_EVENT_CHANNEL_CLOSED                         0x71
337 
338 /**
339  * @format 1BH222
340  * @param status
341  * @param address
342  * @param handle
343  * @param psm
344  * @param local_cid
345  * @param remote_cid
346  */
347 #define L2CAP_EVENT_INCOMING_CONNECTION                    0x72
348 
349 // ??
350 // data: event(8), len(8), handle(16)
351 #define L2CAP_EVENT_TIMEOUT_CHECK                          0x73
352 
353 // ??
354 // data: event(8), len(8), local_cid(16), credits(8)
355 #define L2CAP_EVENT_CREDITS                                0x74
356 
357 /**
358  * @format 12
359  * @param status
360  * @param psm
361  */
362 #define L2CAP_EVENT_SERVICE_REGISTERED                     0x75
363 
364 /**
365  * @format H2222
366  * @param handle
367  * @param interval_min
368  * @param interval_max
369  * @param latencey
370  * @param timeout_multiplier
371  */
372 #define L2CAP_EVENT_CONNECTION_PARAMETER_UPDATE_REQUEST    0x76
373 
374 // data: event(8), len(8), handle(16), result (16) (0 == ok, 1 == fail)
375  /**
376   * @format H2
377   * @param handle
378   * @result
379   */
380 #define L2CAP_EVENT_CONNECTION_PARAMETER_UPDATE_RESPONSE   0x77
381 
382 /**
383  * @format 2
384  * @param local_cid
385  */
386 #define L2CAP_EVENT_CAN_SEND_NOW                           0x78
387 
388 // RFCOMM EVENTS
389 
390 /**
391  * @format 1B2122
392  * @param status
393  * @param bd_addr
394  * @param con_handle
395  * @param server_channel
396  * @param rfcomm_cid
397  * @param max_frame_size
398  */
399 #define RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE                 0x80
400 
401 /**
402  * @format 2
403  * @param rfcomm_cid
404  */
405 #define RFCOMM_EVENT_CHANNEL_CLOSED                        0x81
406 
407 /**
408  * @format B12
409  * @param bd_addr
410  * @param server_channel
411  * @param rfcomm_cid
412  */
413 #define RFCOMM_EVENT_INCOMING_CONNECTION                   0x82
414 
415 /**
416  * @format 21
417  * @param rfcomm_cid
418  * @param line_status
419  */
420 #define RFCOMM_EVENT_REMOTE_LINE_STATUS                    0x83
421 
422 /**
423  * @format 21
424  * @param rfcomm_cid
425  * @param credits
426  */
427 #define RFCOMM_EVENT_CREDITS                               0x84
428 
429 /**
430  * @format 11
431  * @param status
432  * @param channel_id
433  */
434 #define RFCOMM_EVENT_SERVICE_REGISTERED                    0x85
435 
436 /**
437  * @format 11
438  * @param status
439  * @param server_channel_id
440  */
441 #define RFCOMM_EVENT_PERSISTENT_CHANNEL                    0x86
442 
443 /**
444  * @format 21
445  * @param rfcomm_cid
446  * @param modem_status
447  */
448 #define RFCOMM_EVENT_REMOTE_MODEM_STATUS                   0x87
449 
450  /**
451   * TODO: format for variable data 2?
452   * @param rfcomm_cid
453   * @param rpn_data
454   */
455 #define RFCOMM_EVENT_PORT_CONFIGURATION                    0x88
456 
457 /**
458  * @format 2
459  * @param local_cid
460  */
461 #define RFCOMM_EVENT_CAN_SEND_NOW                          0x89
462 
463 
464 /**
465   * @format 14
466   * @param status
467   * @param service_record_handle
468   */
469 #define SDP_EVENT_SERVICE_REGISTERED                             0x90
470 
471 /**
472  * @format 1
473  * @param status
474  */
475 #define SDP_EVENT_QUERY_COMPLETE                                 0x91
476 
477 /**
478  * @format 1T
479  * @param rfcomm_channel
480  * @param name
481  */
482 #define SDP_EVENT_QUERY_RFCOMM_SERVICE                           0x92
483 
484 /**
485  * @format 22221
486  * @param record_id
487  * @param attribute_id
488  * @param attribute_length
489  * @param data_offset
490  * @param data
491  */
492 #define SDP_EVENT_QUERY_ATTRIBUTE_BYTE                           0x93
493 
494 /**
495  * @format 22LV
496  * @param record_id
497  * @param attribute_id
498  * @param attribute_length
499  * @param attribute_value
500  */
501 #define SDP_EVENT_QUERY_ATTRIBUTE_VALUE                          0x94
502 
503 /**
504  * @format 224
505  * @param total_count
506  * @param record_index
507  * @param record_handle
508  * @note Not provided by daemon, only used for internal testing
509  */
510 #define SDP_EVENT_QUERY_SERVICE_RECORD_HANDLE                    0x95
511 
512 /**
513  * @format H1
514  * @param handle
515  * @param status
516  */
517 #define GATT_EVENT_QUERY_COMPLETE                                0xA0
518 
519 /**
520  * @format HX
521  * @param handle
522  * @param service
523  */
524 #define GATT_EVENT_SERVICE_QUERY_RESULT                          0xA1
525 
526 /**
527  * @format HY
528  * @param handle
529  * @param characteristic
530  */
531 #define GATT_EVENT_CHARACTERISTIC_QUERY_RESULT                   0xA2
532 
533 /**
534  * @format H2X
535  * @param handle
536  * @param include_handle
537  * @param service
538  */
539 #define GATT_EVENT_INCLUDED_SERVICE_QUERY_RESULT                 0xA3
540 
541 /**
542  * @format HZ
543  * @param handle
544  * @param characteristic_descriptor
545  */
546 #define GATT_EVENT_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT   0xA4
547 
548 /**
549  * @format H2LV
550  * @param handle
551  * @param value_handle
552  * @param value_length
553  * @param value
554  */
555 #define GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT             0xA5
556 
557 /**
558  * @format H22LV
559  * @param handle
560  * @param value_handle
561  * @param value_offset
562  * @param value_length
563  * @param value
564  */
565 #define GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT        0xA6
566 
567 /**
568  * @format H2LV
569  * @param handle
570  * @param value_handle
571  * @param value_length
572  * @param value
573  */
574 #define GATT_EVENT_NOTIFICATION                                  0xA7
575 
576 /**
577  * @format H2LV
578  * @param handle
579  * @param value_handle
580  * @param value_length
581  * @param value
582  */
583 #define GATT_EVENT_INDICATION                                    0xA8
584 
585 /**
586  * @format H2LV
587  * @param descriptor_handle
588  * @param descriptor_length
589  * @param descriptor
590  */
591 #define GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT        0xA9
592 
593 /**
594  * @format H2LV
595  * @param handle
596  * @param descriptor_offset
597  * @param descriptor_length
598  * @param descriptor
599  */
600 #define GATT_EVENT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT   0xAA
601 
602 /**
603  * @format H2
604  * @param handle
605  * @param MTU
606  */
607 #define GATT_EVENT_MTU                                           0xAB
608 
609 /**
610  * @format H2
611  * @param handle
612  * @param MTU
613  */
614 #define ATT_EVENT_MTU_EXCHANGE_COMPLETE                          0xB5
615 
616 // data: event(8), len(8), status (8), hci_handle (16), attribute_handle (16)
617 #define ATT_EVENT_HANDLE_VALUE_INDICATION_COMPLETE               0xB6
618 
619 
620 // data: event(8), len(8), status (8), bnep service uuid (16)
621 #define BNEP_EVENT_SERVICE_REGISTERED                      0xC0
622 
623 // data: event(8), len(8), status (8), bnep source uuid (16), bnep destination uuid (16), mtu (16), remote_address (48)
624 #define BNEP_EVENT_OPEN_CHANNEL_COMPLETE                   0xC1
625 
626 // data: event(8), len(8), bnep source uuid (16), bnep destination uuid (16), remote_address (48)
627 #define BNEP_EVENT_CHANNEL_CLOSED                          0xC2
628 
629 // data: event(8), len(8), bnep source uuid (16), bnep destination uuid (16), remote_address (48), channel state (8)
630 #define BNEP_EVENT_CHANNEL_TIMEOUT                         0xC3
631 
632 // data: event(8), len(8)
633 #define BNEP_EVENT_READY_TO_SEND                           0xC4
634 
635  /**
636   * @format H1B
637   * @param handle
638   * @param addr_type
639   * @param address
640   */
641 #define SM_EVENT_JUST_WORKS_REQUEST                              0xD0
642 
643  /**
644   * @format H1B
645   * @param handle
646   * @param addr_type
647   * @param address
648   */
649 #define SM_EVENT_JUST_WORKS_CANCEL                               0xD1
650 
651  /**
652   * @format H1B4
653   * @param handle
654   * @param addr_type
655   * @param address
656   * @param passkey
657   */
658 #define SM_EVENT_PASSKEY_DISPLAY_NUMBER                          0xD2
659 
660  /**
661   * @format H1B
662   * @param handle
663   * @param addr_type
664   * @param address
665   */
666 #define SM_EVENT_PASSKEY_DISPLAY_CANCEL                          0xD3
667 
668  /**
669   * @format H1B421
670   * @param handle
671   * @param addr_type
672   * @param address
673   */
674 #define SM_EVENT_PASSKEY_INPUT_NUMBER                            0xD4
675 
676  /**
677   * @format H1B
678   * @param handle
679   * @param addr_type
680   * @param address
681   */
682 #define SM_EVENT_PASSKEY_INPUT_CANCEL                            0xD5
683 
684  /**
685   * @format H1B
686   * @param handle
687   * @param addr_type
688   * @param address
689   */
690 #define SM_EVENT_IDENTITY_RESOLVING_STARTED                      0xD6
691 
692  /**
693   * @format H1B
694   * @param handle
695   * @param addr_type
696   * @param address
697   */
698 #define SM_EVENT_IDENTITY_RESOLVING_FAILED                       0xD7
699 
700  /**
701   * @format H1B2
702   * @param handle
703   * @param addr_type
704   * @param address
705   * @param le_device_db_index
706   */
707 #define SM_EVENT_IDENTITY_RESOLVING_SUCCEEDED                    0xD8
708 
709  /**
710   * @format H1B
711   * @param handle
712   * @param addr_type
713   * @param address
714   */
715 #define SM_EVENT_AUTHORIZATION_REQUEST                           0xD9
716 
717  /**
718   * @format H1B1
719   * @param handle
720   * @param addr_type
721   * @param address
722   * @param authorization_result
723   */
724 #define SM_EVENT_AUTHORIZATION_RESULT                            0xDA
725 
726 // GAP
727 
728 // data: event(8), len(8), hci_handle (16), security_level (8)
729 #define GAP_EVENT_SECURITY_LEVEL                                 0xE0
730 
731 // data: event(8), len(8), status (8), bd_addr(48)
732 #define GAP_EVENT_DEDICATED_BONDING_COMPLETED                    0xE1
733 
734 /**
735  * @format 11B1JV
736  * @param advertising_event_type
737  * @param address_type
738  * @param address
739  * @param rssi
740  * @param data_length
741  * @param data
742  */
743 #define GAP_LE_EVENT_ADVERTISING_REPORT                          0xE2
744 
745 
746 #define HCI_EVENT_HSP_META                                 0xE8
747 
748 /**
749  * @format 11
750  * @param subevent_code
751  * @param status 0 == OK
752  */
753 #define HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE             0x01
754 
755 /**
756  * @format 11
757  * @param subevent_code
758  * @param status 0 == OK
759  */
760 #define HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE          0x02
761 
762 /**
763  * @format 1
764  * @param subevent_code
765  */
766 #define HSP_SUBEVENT_RING                                  0x03
767 
768 /**
769  * @format 11
770  * @param subevent_code
771  * @param gain Valid range: [0,15]
772  */
773 #define HSP_SUBEVENT_MICROPHONE_GAIN_CHANGED               0x04
774 
775 /**
776  * @format 11
777  * @param subevent_code
778  * @param gain Valid range: [0,15]
779  */
780 #define HSP_SUBEVENT_SPEAKER_GAIN_CHANGED                  0x05
781 
782 /**
783  * @format 1JV
784  * @param subevent_code
785  * @param value_length
786  * @param value
787  */
788 #define HSP_SUBEVENT_HS_COMMAND                            0x06
789 
790 /**
791  * @format 1JV
792  * @param subevent_code
793  * @param value_length
794  * @param value
795  */
796 #define HSP_SUBEVENT_AG_INDICATION                         0x07
797 
798 
799 #define HCI_EVENT_HFP_META                                 0xE9
800 
801 #define HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_ESTABLISHED  0x01
802 #define HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED     0x02
803 #define HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED          0x03
804 #define HFP_SUBEVENT_AUDIO_CONNECTION_RELEASED             0x04
805 #define HFP_SUBEVENT_COMPLETE                              0x05
806 #define HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED           0x06
807 #define HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED              0x07
808 #define HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR          0x08
809 #define HFP_SUBEVENT_CODECS_CONNECTION_COMPLETE            0x09
810 #define HFP_SUBEVENT_START_RINGINIG                        0x0A
811 #define HFP_SUBEVENT_STOP_RINGINIG                         0x0B
812 #define HFP_SUBEVENT_CALL_TERMINATED                       0x0C
813 #define HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER                0x0D
814 #define HFP_SUBEVENT_REDIAL_LAST_NUMBER                    0x0E
815 #define HFP_SUBEVENT_ATTACH_NUMBER_TO_VOICE_TAG            0x0F
816 #define HFP_SUBEVENT_NUMBER_FOR_VOICE_TAG                  0x10
817 #define HFP_SUBEVENT_TRANSMIT_DTMF_CODES                   0x11
818 #define HFP_SUBEVENT_TRANSMIT_STATUS_OF_CURRENT_CALL       0x12
819 #define HFP_SUBEVENT_CALL_ANSWERED                         0x13
820 #define HFP_SUBEVENT_CONFERENCE_CALL                       0x14
821 #define HFP_SUBEVENT_RING                                  0x15
822 #define HFP_SUBEVENT_SPEAKER_VOLUME                        0x16
823 #define HFP_SUBEVENT_MICROPHONE_VOLUME                     0x17
824 
825 // ANCS Client
826 
827 /**
828  * @format H
829  * @param handle
830  */
831 #define ANCS_EVENT_CLIENT_CONNECTED                              0xF0
832 
833 /**
834  * @format H2T
835  * @param handle
836  * @param attribute_id
837  * @param text
838  */
839 #define ANCS_EVENT_CLIENT_NOTIFICATION                           0xF1
840 
841 /**
842  * @format H
843  * @param handle
844  */
845 #define ANCS_EVENT_CLIENT_DISCONNECTED                           0xF2
846 
847 // #define HCI_EVENT_HFP_META                                 0xxx
848 // #define HCI_EVENT_GATT_META                                0xxx
849 // #define HCI_EVENT_SDP_META                                 0xxx
850 // #define HCI_EVENT_ANCS_META                                0xxx
851 // #define HCI_EVENT_SM_META                                  0xxx
852 // #define HCI_EVENT_GAP_META                                 0xxx
853 // #define HCI_EVENT_BNEP_META                                0xxx
854 // #define HCI_EVENT_PAN_META                                 0xxx
855 
856 #endif
857