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