xref: /btstack/src/btstack_defines.h (revision 491288c88e8c75fbb441e862ef3d0cf835600d41)
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 
50 // UNUSED macro
51 #define UNUSED(x) (void)(sizeof(x))
52 
53 // TYPES
54 
55 // packet handler
56 typedef void (*btstack_packet_handler_t) (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
57 
58 // packet callback supporting multiple registrations
59 typedef struct {
60     btstack_linked_item_t    item;
61     btstack_packet_handler_t callback;
62 } btstack_packet_callback_registration_t;
63 
64 /**
65  * @brief 128 bit key used with AES128 in Security Manager
66  */
67 typedef uint8_t sm_key_t[16];
68 
69 // DEFINES
70 
71 #define DAEMON_EVENT_PACKET     0x05
72 
73 // L2CAP data
74 #define L2CAP_DATA_PACKET       0x06
75 
76 // RFCOMM data
77 #define RFCOMM_DATA_PACKET      0x07
78 
79 // Attribute protocol data
80 #define ATT_DATA_PACKET         0x08
81 
82 // Security Manager protocol data
83 #define SM_DATA_PACKET          0x09
84 
85 // SDP query result
86 // format: type (8), record_id (16), attribute_id (16), attribute_length (16), attribute_value (max 1k)
87 #define SDP_CLIENT_PACKET       0x0a
88 
89 // BNEP data
90 #define BNEP_DATA_PACKET        0x0b
91 
92 // Unicast Connectionless Data
93 #define UCD_DATA_PACKET         0x0c
94 
95 // debug log messages
96 #define LOG_MESSAGE_PACKET      0xfc
97 
98 
99 // ERRORS
100 
101 // last error code in 2.1 is 0x38 - we start with 0x50 for BTstack errors
102 #define BTSTACK_CONNECTION_TO_BTDAEMON_FAILED              0x50
103 #define BTSTACK_ACTIVATION_FAILED_SYSTEM_BLUETOOTH         0x51
104 #define BTSTACK_ACTIVATION_POWERON_FAILED                  0x52
105 #define BTSTACK_ACTIVATION_FAILED_UNKNOWN                  0x53
106 #define BTSTACK_NOT_ACTIVATED                              0x54
107 #define BTSTACK_BUSY                                       0x55
108 #define BTSTACK_MEMORY_ALLOC_FAILED                        0x56
109 #define BTSTACK_ACL_BUFFERS_FULL                           0x57
110 
111 // l2cap errors - enumeration by the command that created them
112 #define L2CAP_COMMAND_REJECT_REASON_COMMAND_NOT_UNDERSTOOD 0x60
113 #define L2CAP_COMMAND_REJECT_REASON_SIGNALING_MTU_EXCEEDED 0x61
114 #define L2CAP_COMMAND_REJECT_REASON_INVALID_CID_IN_REQUEST 0x62
115 
116 #define L2CAP_CONNECTION_RESPONSE_RESULT_SUCCESSFUL        0x63
117 #define L2CAP_CONNECTION_RESPONSE_RESULT_PENDING           0x64
118 #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_PSM       0x65
119 #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_SECURITY  0x66
120 #define L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_RESOURCES 0x67
121 #define L2CAP_CONNECTION_RESPONSE_RESULT_RTX_TIMEOUT       0x68
122 
123 #define L2CAP_SERVICE_ALREADY_REGISTERED                   0x69
124 #define L2CAP_DATA_LEN_EXCEEDS_REMOTE_MTU                  0x6A
125 #define L2CAP_SERVICE_DOES_NOT_EXIST                       0x6B
126 #define L2CAP_LOCAL_CID_DOES_NOT_EXIST                     0x6C
127 
128 #define RFCOMM_MULTIPLEXER_STOPPED                         0x70
129 #define RFCOMM_CHANNEL_ALREADY_REGISTERED                  0x71
130 #define RFCOMM_NO_OUTGOING_CREDITS                         0x72
131 #define RFCOMM_AGGREGATE_FLOW_OFF                          0x73
132 #define RFCOMM_DATA_LEN_EXCEEDS_MTU                        0x74
133 
134 #define SDP_HANDLE_ALREADY_REGISTERED                      0x80
135 #define SDP_QUERY_INCOMPLETE                               0x81
136 #define SDP_SERVICE_NOT_FOUND                              0x82
137 #define SDP_HANDLE_INVALID                                 0x83
138 #define SDP_QUERY_BUSY                                     0x84
139 
140 #define ATT_HANDLE_VALUE_INDICATION_IN_PORGRESS            0x90
141 #define ATT_HANDLE_VALUE_INDICATION_TIMEOUT                0x91
142 
143 #define GATT_CLIENT_NOT_CONNECTED                          0x93
144 #define GATT_CLIENT_BUSY                                   0x94
145 #define GATT_CLIENT_IN_WRONG_STATE                         0x95
146 #define GATT_CLIENT_DIFFERENT_CONTEXT_FOR_ADDRESS_ALREADY_EXISTS 0x96
147 #define GATT_CLIENT_VALUE_TOO_LONG                         0x97
148 #define GATT_CLIENT_CHARACTERISTIC_NOTIFICATION_NOT_SUPPORTED 0x98
149 #define GATT_CLIENT_CHARACTERISTIC_INDICATION_NOT_SUPPORTED   0x99
150 
151 #define BNEP_SERVICE_ALREADY_REGISTERED                    0xA0
152 #define BNEP_CHANNEL_NOT_CONNECTED                         0xA1
153 #define BNEP_DATA_LEN_EXCEEDS_MTU                          0xA2
154 
155 
156 
157 // DAEMON COMMANDS
158 
159 #define OGF_BTSTACK 0x3d
160 
161 // cmds for BTstack
162 // get state: @returns HCI_STATE
163 #define BTSTACK_GET_STATE                                  0x01
164 
165 // set power mode: param HCI_POWER_MODE
166 #define BTSTACK_SET_POWER_MODE                             0x02
167 
168 // set capture mode: param on
169 #define BTSTACK_SET_ACL_CAPTURE_MODE                       0x03
170 
171 // get BTstack version
172 #define BTSTACK_GET_VERSION                                0x04
173 
174 // get system Bluetooth state
175 #define BTSTACK_GET_SYSTEM_BLUETOOTH_ENABLED               0x05
176 
177 // set system Bluetooth state
178 #define BTSTACK_SET_SYSTEM_BLUETOOTH_ENABLED               0x06
179 
180 // enable inquiry scan for this client
181 #define BTSTACK_SET_DISCOVERABLE                           0x07
182 
183 // set global Bluetooth state
184 #define BTSTACK_SET_BLUETOOTH_ENABLED                      0x08
185 
186 // create l2cap channel: param bd_addr(48), psm (16)
187 #define L2CAP_CREATE_CHANNEL                               0x20
188 
189 // disconnect l2cap disconnect, param channel(16), reason(8)
190 #define L2CAP_DISCONNECT                                   0x21
191 
192 // register l2cap service: param psm(16), mtu (16)
193 #define L2CAP_REGISTER_SERVICE                             0x22
194 
195 // unregister l2cap disconnect, param psm(16)
196 #define L2CAP_UNREGISTER_SERVICE                           0x23
197 
198 // accept connection param bd_addr(48), dest cid (16)
199 #define L2CAP_ACCEPT_CONNECTION                            0x24
200 
201 // decline l2cap disconnect,param bd_addr(48), dest cid (16), reason(8)
202 #define L2CAP_DECLINE_CONNECTION                           0x25
203 
204 // create l2cap channel: param bd_addr(48), psm (16), mtu (16)
205 #define L2CAP_CREATE_CHANNEL_MTU                           0x26
206 
207 // register SDP Service Record: service record (size)
208 #define SDP_REGISTER_SERVICE_RECORD                        0x30
209 
210 // unregister SDP Service Record
211 #define SDP_UNREGISTER_SERVICE_RECORD                      0x31
212 
213 // Get remote RFCOMM services
214 #define SDP_CLIENT_QUERY_RFCOMM_SERVICES                   0x32
215 
216 // Get remote SDP services
217 #define SDP_CLIENT_QUERY_SERVICES                          0x33
218 
219 // RFCOMM "HCI" Commands
220 #define RFCOMM_CREATE_CHANNEL       0x40
221 #define RFCOMM_DISCONNECT     0x41
222 #define RFCOMM_REGISTER_SERVICE     0x42
223 #define RFCOMM_UNREGISTER_SERVICE   0x43
224 #define RFCOMM_ACCEPT_CONNECTION    0x44
225 #define RFCOMM_DECLINE_CONNECTION   0x45
226 #define RFCOMM_PERSISTENT_CHANNEL   0x46
227 #define RFCOMM_CREATE_CHANNEL_WITH_CREDITS   0x47
228 #define RFCOMM_REGISTER_SERVICE_WITH_CREDITS 0x48
229 #define RFCOMM_GRANT_CREDITS                 0x49
230 
231 // GAP Classic 0x50
232 #define GAP_DISCONNECT              0x50
233 
234 // GAP LE      0x60
235 #define GAP_LE_SCAN_START           0x60
236 #define GAP_LE_SCAN_STOP            0x61
237 #define GAP_LE_CONNECT              0x62
238 #define GAP_LE_CONNECT_CANCEL       0x63
239 #define GAP_LE_SET_SCAN_PARAMETERS  0x64
240 
241 // GATT (Client) 0x70
242 #define GATT_DISCOVER_ALL_PRIMARY_SERVICES                       0x70
243 #define GATT_DISCOVER_PRIMARY_SERVICES_BY_UUID16                 0x71
244 #define GATT_DISCOVER_PRIMARY_SERVICES_BY_UUID128                0x72
245 #define GATT_FIND_INCLUDED_SERVICES_FOR_SERVICE                  0x73
246 #define GATT_DISCOVER_CHARACTERISTICS_FOR_SERVICE                0x74
247 #define GATT_DISCOVER_CHARACTERISTICS_FOR_SERVICE_BY_UUID128     0x75
248 #define GATT_DISCOVER_CHARACTERISTIC_DESCRIPTORS                 0x76
249 #define GATT_READ_VALUE_OF_CHARACTERISTIC                        0x77
250 #define GATT_READ_LONG_VALUE_OF_CHARACTERISTIC                   0x78
251 #define GATT_WRITE_VALUE_OF_CHARACTERISTIC_WITHOUT_RESPONSE      0x79
252 #define GATT_WRITE_VALUE_OF_CHARACTERISTIC                       0x7A
253 #define GATT_WRITE_LONG_VALUE_OF_CHARACTERISTIC                  0x7B
254 #define GATT_RELIABLE_WRITE_LONG_VALUE_OF_CHARACTERISTIC         0x7C
255 #define GATT_READ_CHARACTERISTIC_DESCRIPTOR                      0X7D
256 #define GATT_READ_LONG_CHARACTERISTIC_DESCRIPTOR                 0X7E
257 #define GATT_WRITE_CHARACTERISTIC_DESCRIPTOR                     0X7F
258 #define GATT_WRITE_LONG_CHARACTERISTIC_DESCRIPTOR                0X80
259 #define GATT_WRITE_CLIENT_CHARACTERISTIC_CONFIGURATION           0X81
260 #define GATT_GET_MTU                                             0x82
261 
262 
263 
264 // EVENTS
265 
266 /**
267  * @format 1
268  * @param state
269  */
270 #define BTSTACK_EVENT_STATE                                0x60
271 
272 // data: event(8), len(8), nr hci connections
273 #define BTSTACK_EVENT_NR_CONNECTIONS_CHANGED               0x61
274 
275 /**
276  * @format
277  */
278 #define BTSTACK_EVENT_POWERON_FAILED                       0x62
279 
280 /**
281  * @format 1
282  * @param discoverable
283  */
284 #define BTSTACK_EVENT_DISCOVERABLE_ENABLED                 0x66
285 
286 // Daemon Events
287 
288 /**
289  * @format 112
290  * @param major
291  * @param minor
292  @ @param revision
293  */
294 #define DAEMON_EVENT_VERSION                               0x63
295 
296 // data: system bluetooth on/off (bool)
297 /**
298  * @format 1
299  * param system_bluetooth_enabled
300  */
301 #define DAEMON_EVENT_SYSTEM_BLUETOOTH_ENABLED              0x64
302 
303 // data: event (8), len(8), status (8) == 0, address (48), name (1984 bits = 248 bytes)
304 
305 /*
306  * @format 1BT
307  * @param status == 0 to match read_remote_name_request
308  * @param address
309  * @param name
310  */
311 #define DAEMON_EVENT_REMOTE_NAME_CACHED                    0x65
312 
313 // internal - data: event(8)
314 #define DAEMON_EVENT_CONNECTION_OPENED                     0x67
315 
316 // internal - data: event(8)
317 #define DAEMON_EVENT_CONNECTION_CLOSED                     0x68
318 
319 // data: event(8), len(8), local_cid(16), credits(8)
320 #define DAEMON_EVENT_L2CAP_CREDITS                         0x74
321 
322 /**
323  * @format 12
324  * @param status
325  * @param psm
326  */
327 #define DAEMON_EVENT_L2CAP_SERVICE_REGISTERED              0x75
328 
329 /**
330  * @format 21
331  * @param rfcomm_cid
332  * @param credits
333  */
334 #define DAEMON_EVENT_RFCOMM_CREDITS                        0x84
335 
336 /**
337  * @format 11
338  * @param status
339  * @param channel_id
340  */
341 #define DAEMON_EVENT_RFCOMM_SERVICE_REGISTERED             0x85
342 
343 /**
344  * @format 11
345  * @param status
346  * @param server_channel_id
347  */
348 #define DAEMON_EVENT_RFCOMM_PERSISTENT_CHANNEL             0x86
349 
350 /**
351   * @format 14
352   * @param status
353   * @param service_record_handle
354   */
355 #define DAEMON_EVENT_SDP_SERVICE_REGISTERED                0x90
356 
357 
358 
359 // additional HCI events
360 
361 /**
362  * @brief Outgoing packet
363  */
364 #define HCI_EVENT_TRANSPORT_PACKET_SENT                    0x6E
365 
366 /**
367  * @format B
368  * @param handle
369  */
370 #define HCI_EVENT_SCO_CAN_SEND_NOW                         0x6F
371 
372 
373 // L2CAP EVENTS
374 
375 /**
376  * @format 1BH2222221
377  * @param status
378  * @param address
379  * @param handle
380  * @param psm
381  * @param local_cid
382  * @param remote_cid
383  * @param local_mtu
384  * @param remote_mtu
385  * @param flush_timeout
386  * @param incoming
387  */
388 #define L2CAP_EVENT_CHANNEL_OPENED                         0x70
389 
390 /*
391  * @format 2
392  * @param local_cid
393  */
394 #define L2CAP_EVENT_CHANNEL_CLOSED                         0x71
395 
396 /**
397  * @format BH222
398  * @param address
399  * @param handle
400  * @param psm
401  * @param local_cid
402  * @param remote_cid
403  */
404 #define L2CAP_EVENT_INCOMING_CONNECTION                    0x72
405 
406 // ??
407 // data: event(8), len(8), handle(16)
408 #define L2CAP_EVENT_TIMEOUT_CHECK                          0x73
409 
410 /**
411  * @format H2222
412  * @param handle
413  * @param interval_min
414  * @param interval_max
415  * @param latencey
416  * @param timeout_multiplier
417  */
418 #define L2CAP_EVENT_CONNECTION_PARAMETER_UPDATE_REQUEST    0x76
419 
420 // data: event(8), len(8), handle(16), result (16) (0 == ok, 1 == fail)
421  /**
422   * @format H2
423   * @param handle
424   * @result
425   */
426 #define L2CAP_EVENT_CONNECTION_PARAMETER_UPDATE_RESPONSE   0x77
427 
428 /**
429  * @format 2
430  * @param local_cid
431  */
432 #define L2CAP_EVENT_CAN_SEND_NOW                           0x78
433 
434 // LE Data Channels
435 
436 /**
437  * @format 1BH2222
438  * @param address_type
439  * @param address
440  * @param handle
441  * @param psm
442  * @param local_cid
443  * @param remote_cid
444  * @param remote_mtu
445  */
446 #define L2CAP_EVENT_LE_INCOMING_CONNECTION                 0x79
447 
448 /**
449  * @format 11BH122222
450  * @param status
451  * @param address_type
452  * @param address
453  * @param handle
454  * @param incoming
455  * @param psm
456  * @param local_cid
457  * @param remote_cid
458  * @param local_mtu
459  * @param remote_mtu
460  */
461 #define L2CAP_EVENT_LE_CHANNEL_OPENED                      0x7a
462 
463 /*
464  * @format 2
465  * @param local_cid
466  */
467 #define L2CAP_EVENT_LE_CHANNEL_CLOSED                      0x7b
468 
469 /*
470  * @format 2
471  * @param local_cid
472  */
473 #define L2CAP_EVENT_LE_CAN_SEND_NOW                        0x7c
474 
475 /*
476  * @format 2
477  * @param local_cid
478  */
479 #define L2CAP_EVENT_LE_PACKET_SENT                         0x7d
480 
481 
482 // RFCOMM EVENTS
483 
484 /**
485  * @format 1B21221
486  * @param status
487  * @param bd_addr
488  * @param con_handle
489  * @param server_channel
490  * @param rfcomm_cid
491  * @param max_frame_size
492  * @param incoming
493  */
494 #define RFCOMM_EVENT_CHANNEL_OPENED                        0x80
495 
496 /**
497  * @format 2
498  * @param rfcomm_cid
499  */
500 #define RFCOMM_EVENT_CHANNEL_CLOSED                        0x81
501 
502 /**
503  * @format B12
504  * @param bd_addr
505  * @param server_channel
506  * @param rfcomm_cid
507  */
508 #define RFCOMM_EVENT_INCOMING_CONNECTION                   0x82
509 
510 /**
511  * @format 21
512  * @param rfcomm_cid
513  * @param line_status
514  */
515 #define RFCOMM_EVENT_REMOTE_LINE_STATUS                    0x83
516 
517 /**
518  * @format 21
519  * @param rfcomm_cid
520  * @param modem_status
521  */
522 #define RFCOMM_EVENT_REMOTE_MODEM_STATUS                   0x87
523 
524  /**
525   * TODO: format for variable data 2?
526   * param rfcomm_cid
527   * param rpn_data
528   */
529 #define RFCOMM_EVENT_PORT_CONFIGURATION                    0x88
530 
531 /**
532  * @format 2
533  * @param rfcomm_cid
534  */
535 #define RFCOMM_EVENT_CAN_SEND_NOW                          0x89
536 
537 
538 /**
539  * @format 1
540  * @param status
541  */
542 #define SDP_EVENT_QUERY_COMPLETE                                 0x91
543 
544 /**
545  * @format 1T
546  * @param rfcomm_channel
547  * @param name
548  */
549 #define SDP_EVENT_QUERY_RFCOMM_SERVICE                           0x92
550 
551 /**
552  * @format 22221
553  * @param record_id
554  * @param attribute_id
555  * @param attribute_length
556  * @param data_offset
557  * @param data
558  */
559 #define SDP_EVENT_QUERY_ATTRIBUTE_BYTE                           0x93
560 
561 /**
562  * @format 22LV
563  * @param record_id
564  * @param attribute_id
565  * @param attribute_length
566  * @param attribute_value
567  */
568 #define SDP_EVENT_QUERY_ATTRIBUTE_VALUE                          0x94
569 
570 /**
571  * @format 224
572  * @param total_count
573  * @param record_index
574  * @param record_handle
575  * @note Not provided by daemon, only used for internal testing
576  */
577 #define SDP_EVENT_QUERY_SERVICE_RECORD_HANDLE                    0x95
578 
579 /**
580  * @format H1
581  * @param handle
582  * @param status
583  */
584 #define GATT_EVENT_QUERY_COMPLETE                                0xA0
585 
586 /**
587  * @format HX
588  * @param handle
589  * @param service
590  */
591 #define GATT_EVENT_SERVICE_QUERY_RESULT                          0xA1
592 
593 /**
594  * @format HY
595  * @param handle
596  * @param characteristic
597  */
598 #define GATT_EVENT_CHARACTERISTIC_QUERY_RESULT                   0xA2
599 
600 /**
601  * @format H2X
602  * @param handle
603  * @param include_handle
604  * @param service
605  */
606 #define GATT_EVENT_INCLUDED_SERVICE_QUERY_RESULT                 0xA3
607 
608 /**
609  * @format HZ
610  * @param handle
611  * @param characteristic_descriptor
612  */
613 #define GATT_EVENT_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT   0xA4
614 
615 /**
616  * @format H2LV
617  * @param handle
618  * @param value_handle
619  * @param value_length
620  * @param value
621  */
622 #define GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT             0xA5
623 
624 /**
625  * @format H22LV
626  * @param handle
627  * @param value_handle
628  * @param value_offset
629  * @param value_length
630  * @param value
631  */
632 #define GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT        0xA6
633 
634 /**
635  * @format H2LV
636  * @param handle
637  * @param value_handle
638  * @param value_length
639  * @param value
640  */
641 #define GATT_EVENT_NOTIFICATION                                  0xA7
642 
643 /**
644  * @format H2LV
645  * @param handle
646  * @param value_handle
647  * @param value_length
648  * @param value
649  */
650 #define GATT_EVENT_INDICATION                                    0xA8
651 
652 /**
653  * @format H2LV
654  * @param descriptor_handle
655  * @param descriptor_length
656  * @param descriptor
657  */
658 #define GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT        0xA9
659 
660 /**
661  * @format H2LV
662  * @param handle
663  * @param descriptor_offset
664  * @param descriptor_length
665  * @param descriptor
666  */
667 #define GATT_EVENT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT   0xAA
668 
669 /**
670  * @format H2
671  * @param handle
672  * @param MTU
673  */
674 #define GATT_EVENT_MTU                                           0xAB
675 
676 /**
677  * @format H2
678  * @param handle
679  * @param MTU
680  */
681 #define ATT_EVENT_MTU_EXCHANGE_COMPLETE                          0xB5
682 
683  /**
684   * @format 1H2
685   * @param status
686   * @param conn_handle
687   * @param attribute_handle
688   */
689 #define ATT_EVENT_HANDLE_VALUE_INDICATION_COMPLETE               0xB6
690 
691 /**
692  * @format
693  */
694 #define ATT_EVENT_CAN_SEND_NOW                                   0xB7
695 
696 // TODO: daemon only event
697 
698 /**
699  * @format 12
700  * @param status
701  * @param service_uuid
702  */
703  #define BNEP_EVENT_SERVICE_REGISTERED                      0xC0
704 
705 /**
706  * @format 12222B
707  * @param status
708  * @param bnep_cid
709  * @param source_uuid
710  * @param destination_uuid
711  * @param mtu
712  * @param remote_address
713  */
714  #define BNEP_EVENT_CHANNEL_OPENED                   0xC1
715 
716 /**
717  * @format 222B
718  * @param bnep_cid
719  * @param source_uuid
720  * @param destination_uuid
721  * @param remote_address
722  */
723  #define BNEP_EVENT_CHANNEL_CLOSED                          0xC2
724 
725 /**
726  * @format 222B1
727  * @param bnep_cid
728  * @param source_uuid
729  * @param destination_uuid
730  * @param remote_address
731  * @param channel_state
732  */
733 #define BNEP_EVENT_CHANNEL_TIMEOUT                         0xC3
734 
735 /**
736  * @format 222B
737  * @param bnep_cid
738  * @param source_uuid
739  * @param destination_uuid
740  * @param remote_address
741  */
742  #define BNEP_EVENT_CAN_SEND_NOW                           0xC4
743 
744  /**
745   * @format H1B
746   * @param handle
747   * @param addr_type
748   * @param address
749   */
750 #define SM_EVENT_JUST_WORKS_REQUEST                              0xD0
751 
752  /**
753   * @format H1B
754   * @param handle
755   * @param addr_type
756   * @param address
757   */
758 #define SM_EVENT_JUST_WORKS_CANCEL                               0xD1
759 
760  /**
761   * @format H1B4
762   * @param handle
763   * @param addr_type
764   * @param address
765   * @param passkey
766   */
767 #define SM_EVENT_PASSKEY_DISPLAY_NUMBER                          0xD2
768 
769  /**
770   * @format H1B
771   * @param handle
772   * @param addr_type
773   * @param address
774   */
775 #define SM_EVENT_PASSKEY_DISPLAY_CANCEL                          0xD3
776 
777  /**
778   * @format H1B421
779   * @param handle
780   * @param addr_type
781   * @param address
782   */
783 #define SM_EVENT_PASSKEY_INPUT_NUMBER                            0xD4
784 
785  /**
786   * @format H1B
787   * @param handle
788   * @param addr_type
789   * @param address
790   */
791 #define SM_EVENT_PASSKEY_INPUT_CANCEL                            0xD5
792 
793  /**
794   * @format H1B4
795   * @param handle
796   * @param addr_type
797   * @param address
798   * @param passkey
799   */
800 #define SM_EVENT_NUMERIC_COMPARISON_REQUEST                      0xD6
801 
802  /**
803   * @format H1B4
804   * @param handle
805   * @param addr_type
806   * @param address
807   */
808 #define SM_EVENT_NUMERIC_COMPARISON_CANCEL                       0xD7
809 
810  /**
811   * @format H1B
812   * @param handle
813   * @param addr_type
814   * @param address
815   */
816 #define SM_EVENT_IDENTITY_RESOLVING_STARTED                      0xD8
817 
818  /**
819   * @format H1B
820   * @param handle
821   * @param addr_type
822   * @param address
823   */
824 #define SM_EVENT_IDENTITY_RESOLVING_FAILED                       0xD9
825 
826  /**
827   * @brief Identify resolving succeeded
828   *
829   * @format H1B1B
830   * @param handle
831   * @param addr_type
832   * @param address
833   * @param identity_addr_type
834   * @param identity_address
835   *
836   * @note le_device_db_index was removed, please use provided identity information directly
837   *
838   */
839 #define SM_EVENT_IDENTITY_RESOLVING_SUCCEEDED                    0xDA
840 
841  /**
842   * @format H1B
843   * @param handle
844   * @param addr_type
845   * @param address
846   */
847 #define SM_EVENT_AUTHORIZATION_REQUEST                           0xDB
848 
849  /**
850   * @format H1B1
851   * @param handle
852   * @param addr_type
853   * @param address
854   * @param authorization_result
855   */
856 #define SM_EVENT_AUTHORIZATION_RESULT                            0xDC
857 
858  /**
859   * @format H1
860   * @param handle
861   * @param action see SM_KEYPRESS_*
862   */
863 #define SM_EVENT_KEYPRESS_NOTIFICATION                           0xDD
864 
865  /**
866   * @brief Emitted during pairing to inform app about address used as identity
867   *
868   * @format H1B1B
869   * @param handle
870   * @param addr_type
871   * @param address
872   * @param identity_addr_type
873   * @param identity_address
874   */
875 #define SM_EVENT_IDENTITY_CREATED                                0xDE
876 
877 // GAP
878 
879 /**
880  * @format H1
881  * @param handle
882  * @param security_level
883  */
884 #define GAP_EVENT_SECURITY_LEVEL                                 0xE0
885 
886 /**
887  * @format 1B
888  * @param status
889  * @param address
890  */
891 #define GAP_EVENT_DEDICATED_BONDING_COMPLETED                    0xE1
892 
893 /**
894  * @format 11B1JV
895  * @param advertising_event_type
896  * @param address_type
897  * @param address
898  * @param rssi
899  * @param data_length
900  * @param data
901  */
902 #define GAP_EVENT_ADVERTISING_REPORT                          0xE2
903 
904 
905 // Meta Events, see below for sub events
906 #define HCI_EVENT_HSP_META                                 0xE8
907 #define HCI_EVENT_HFP_META                                 0xE9
908 #define HCI_EVENT_ANCS_META                                0xEA
909 
910 // Potential other meta groups
911  // #define HCI_EVENT_BNEP_META                                0xxx
912 // #define HCI_EVENT_GAP_META                                 0xxx
913 // #define HCI_EVENT_GATT_META                                0xxx
914 // #define HCI_EVENT_PAN_META                                 0xxx
915 // #define HCI_EVENT_SDP_META                                 0xxx
916 // #define HCI_EVENT_SM_META                                  0xxx
917 
918 
919 /** HSP Subevent */
920 
921 /**
922  * @format 11
923  * @param subevent_code
924  * @param status 0 == OK
925  */
926 #define HSP_SUBEVENT_RFCOMM_CONNECTION_COMPLETE             0x01
927 
928 /**
929  * @format 11
930  * @param subevent_code
931  * @param status 0 == OK
932  */
933 #define HSP_SUBEVENT_RFCOMM_DISCONNECTION_COMPLETE           0x02
934 
935 
936 /**
937  * @format 11H
938  * @param subevent_code
939  * @param status 0 == OK
940  * @param handle
941  */
942 #define HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE             0x03
943 
944 /**
945  * @format 11
946  * @param subevent_code
947  * @param status 0 == OK
948  */
949 #define HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE          0x04
950 
951 /**
952  * @format 1
953  * @param subevent_code
954  */
955 #define HSP_SUBEVENT_RING                                  0x05
956 
957 /**
958  * @format 11
959  * @param subevent_code
960  * @param gain Valid range: [0,15]
961  */
962 #define HSP_SUBEVENT_MICROPHONE_GAIN_CHANGED               0x06
963 
964 /**
965  * @format 11
966  * @param subevent_code
967  * @param gain Valid range: [0,15]
968  */
969 #define HSP_SUBEVENT_SPEAKER_GAIN_CHANGED                  0x07
970 
971 /**
972  * @format 1JV
973  * @param subevent_code
974  * @param value_length
975  * @param value
976  */
977 #define HSP_SUBEVENT_HS_COMMAND                            0x08
978 
979 /**
980  * @format 1JV
981  * @param subevent_code
982  * @param value_length
983  * @param value
984  */
985 #define HSP_SUBEVENT_AG_INDICATION                         0x09
986 
987 
988 /** HFP Subevent */
989 
990 /**
991  * @format 11HB1
992  * @param subevent_code
993  * @param status 0 == OK
994  * @param con_handle
995  * @param bd_addr
996  */
997 #define HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_ESTABLISHED  0x01
998 
999 /**
1000  * @format 1
1001  * @param subevent_code
1002  */
1003 #define HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED     0x02
1004 
1005 /**
1006  * @format 11HB11
1007  * @param subevent_code
1008  * @param status 0 == OK
1009  * @param handle
1010  * @param bd_addr
1011  * @param negotiated_codec
1012  */
1013 #define HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED          0x03
1014 
1015 /**
1016  * @format 1
1017  * @param subevent_code
1018  */
1019 #define HFP_SUBEVENT_AUDIO_CONNECTION_RELEASED             0x04
1020 
1021 /**
1022  * @format 11
1023  * @param subevent_code
1024  * @param status 0 == OK
1025  */
1026 #define HFP_SUBEVENT_COMPLETE                              0x05
1027 
1028 /**
1029  * @format 111T
1030  * @param subevent_code
1031  * @param indicator_index
1032  * @param indicator_status
1033  * @param indicator_name
1034  */
1035 #define HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED           0x06
1036 
1037 /**
1038  * @format 1111T
1039  * @param subevent_code
1040  * @param network_operator_mode
1041  * @param network_operator_format
1042  * @param network_operator_name
1043  */
1044 #define HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED              0x07
1045 
1046 /**
1047  * @format 11
1048  * @param subevent_code
1049  * @param error
1050  */
1051 #define HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR             0x08
1052 
1053 /**
1054  * @format 1
1055  * @param subevent_code
1056  */
1057 #define HFP_SUBEVENT_START_RINGINIG                           0x0A
1058 
1059 /**
1060  * @format 1
1061  * @param subevent_code
1062  */
1063 #define HFP_SUBEVENT_STOP_RINGINIG                            0x0B
1064 
1065 /**
1066  * @format 1
1067  * @param subevent_code
1068  */
1069 #define HFP_SUBEVENT_CALL_TERMINATED                          0x0C
1070 
1071 /**
1072  * @format 1T
1073  * @param subevent_code
1074  * @param number
1075  */
1076 #define HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER                   0x0D
1077 
1078 /**
1079  * @format 1
1080  * @param subevent_code
1081  */
1082 #define HFP_SUBEVENT_ATTACH_NUMBER_TO_VOICE_TAG               0x0E
1083 
1084 /**
1085  * @format 1T
1086  * @param subevent_code
1087  * @param number
1088  */
1089 #define HFP_SUBEVENT_NUMBER_FOR_VOICE_TAG                     0x0F
1090 
1091 /**
1092  * @format 1T
1093  * @param subevent_code
1094  * @param dtmf code
1095  */
1096 #define HFP_SUBEVENT_TRANSMIT_DTMF_CODES                      0x10
1097 
1098 /**
1099  * @format 1
1100  * @param subevent_code
1101  */
1102  #define HFP_SUBEVENT_CALL_ANSWERED                            0x11
1103 
1104 /**
1105  * @format 1
1106  * @param subevent_code
1107  */
1108 #define HFP_SUBEVENT_CONFERENCE_CALL                          0x12
1109 
1110 /**
1111  * @format 1
1112  * @param subevent_code
1113  */
1114 #define HFP_SUBEVENT_RING                                     0x13
1115 
1116 /**
1117  * @format 111
1118  * @param subevent_code
1119  * @param status
1120  * @param gain
1121  */
1122  #define HFP_SUBEVENT_SPEAKER_VOLUME                           0x14
1123 
1124 /**
1125  * @format 111
1126  * @param subevent_code
1127  * @param status
1128  * @param gain
1129  */
1130 #define HFP_SUBEVENT_MICROPHONE_VOLUME                        0x15
1131 
1132 /**
1133  * @format 11T
1134  * @param subevent_code
1135  * @param type
1136  * @param number
1137  */
1138 #define HFP_SUBEVENT_CALL_WAITING_NOTIFICATION                0x16
1139 
1140 /**
1141  * @format 11T
1142  * @param subevent_code
1143  * @param type
1144  * @param number
1145  */
1146 #define HFP_SUBEVENT_CALLING_LINE_INDETIFICATION_NOTIFICATION 0x17
1147 
1148 /**
1149  * @format 111111T
1150  * @param subevent_code
1151  * @param clcc_idx
1152  * @param clcc_dir
1153  * @param clcc_status
1154  * @param clcc_mpty
1155  * @param bnip_type
1156  * @param bnip_number
1157  */
1158 #define HFP_SUBEVENT_ENHANCED_CALL_STATUS                     0x18
1159 
1160 /**
1161  * @format 111T
1162  * @param subevent_code
1163  * @param status
1164  * @param bnip_type
1165  * @param bnip_number
1166  */
1167  #define HFP_SUBEVENT_SUBSCRIBER_NUMBER_INFORMATION            0x19
1168 
1169 /**
1170  * @format 1T
1171  * @param subevent_code
1172  * @param value
1173  */
1174 #define HFP_SUBEVENT_RESPONSE_AND_HOLD_STATUS                 0x1A
1175 
1176 // ANCS Client
1177 
1178 /**
1179  * @format 1H
1180  * @param subevent_code
1181  * @param handle
1182  */
1183 #define ANCS_SUBEVENT_CLIENT_CONNECTED                              0xF0
1184 
1185 /**
1186  * @format 1H2T
1187  * @param subevent_code
1188  * @param handle
1189  * @param attribute_id
1190  * @param text
1191  */
1192 #define ANCS_SUBEVENT_CLIENT_NOTIFICATION                           0xF1
1193 
1194 /**
1195  * @format 1H
1196  * @param subevent_code
1197  * @param handle
1198  */
1199 #define ANCS_SUBEVENT_CLIENT_DISCONNECTED                           0xF2
1200 
1201 #endif
1202