xref: /btstack/src/btstack_event.h (revision 72b5080138ca1eba9e375ff9ba0b384dc8c9f3b3)
1 /*
2  * Copyright (C) 2016 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 /*
40  *  btstack_event.h
41  *
42  *  @brief BTstack event getter/setter
43  *  @note  Don't edit - generated by tool/btstack_event_generator.py
44  *
45  */
46 
47 #ifndef __BTSTACK_EVENT_H
48 #define __BTSTACK_EVENT_H
49 
50 #if defined __cplusplus
51 extern "C" {
52 #endif
53 
54 #include "btstack_util.h"
55 #include <stdint.h>
56 
57 /* API_START */
58 
59 
60 /**
61  * @brief Get field status from event sdp_event_service_registered
62  * @param Event packet
63  * @return status
64  * @note: btstack_type 1
65  */
66 static inline uint8_t sdp_event_service_registered_get_status(const uint8_t * event){
67     return event[2];
68 }
69 
70 /**
71  * @brief Get field service_record_handle from event sdp_event_service_registered
72  * @param Event packet
73  * @return service_record_handle
74  * @note: btstack_type 4
75  */
76 static inline uint32_t sdp_event_service_registered_get_service_record_handle(const uint8_t * event){
77     return little_endian_read_32(event, 3);
78 }
79 
80 /**
81  * @brief Get field status from event sdp_event_query_complete
82  * @param Event packet
83  * @return status
84  * @note: btstack_type 1
85  */
86 static inline uint8_t sdp_event_query_complete_get_status(const uint8_t * event){
87     return event[2];
88 }
89 
90 /**
91  * @brief Get field rfcomm_channel from event sdp_event_query_rfcomm_service
92  * @param Event packet
93  * @return rfcomm_channel
94  * @note: btstack_type 1
95  */
96 static inline uint8_t sdp_event_query_rfcomm_service_get_rfcomm_channel(const uint8_t * event){
97     return event[2];
98 }
99 
100 /**
101  * @brief Get field name from event sdp_event_query_rfcomm_service
102  * @param Event packet
103  * @return name
104  * @note: btstack_type T
105  */
106 static inline const char * sdp_event_query_rfcomm_service_get_name(const uint8_t * event){
107     return (const char *) &event[3];
108 }
109 
110 /**
111  * @brief Get field record_id from event sdp_event_query_attribute_byte
112  * @param Event packet
113  * @return record_id
114  * @note: btstack_type 2
115  */
116 static inline uint16_t sdp_event_query_attribute_byte_get_record_id(const uint8_t * event){
117     return little_endian_read_16(event, 2);
118 }
119 
120 /**
121  * @brief Get field attribute_id from event sdp_event_query_attribute_byte
122  * @param Event packet
123  * @return attribute_id
124  * @note: btstack_type 2
125  */
126 static inline uint16_t sdp_event_query_attribute_byte_get_attribute_id(const uint8_t * event){
127     return little_endian_read_16(event, 4);
128 }
129 
130 /**
131  * @brief Get field attribute_length from event sdp_event_query_attribute_byte
132  * @param Event packet
133  * @return attribute_length
134  * @note: btstack_type 2
135  */
136 static inline uint16_t sdp_event_query_attribute_byte_get_attribute_length(const uint8_t * event){
137     return little_endian_read_16(event, 6);
138 }
139 
140 /**
141  * @brief Get field data_offset from event sdp_event_query_attribute_byte
142  * @param Event packet
143  * @return data_offset
144  * @note: btstack_type 2
145  */
146 static inline uint16_t sdp_event_query_attribute_byte_get_data_offset(const uint8_t * event){
147     return little_endian_read_16(event, 8);
148 }
149 
150 /**
151  * @brief Get field data from event sdp_event_query_attribute_byte
152  * @param Event packet
153  * @return data
154  * @note: btstack_type 1
155  */
156 static inline uint8_t sdp_event_query_attribute_byte_get_data(const uint8_t * event){
157     return event[10];
158 }
159 
160 /**
161  * @brief Get field record_id from event sdp_event_query_attribute_value
162  * @param Event packet
163  * @return record_id
164  * @note: btstack_type 2
165  */
166 static inline uint16_t sdp_event_query_attribute_value_get_record_id(const uint8_t * event){
167     return little_endian_read_16(event, 2);
168 }
169 
170 /**
171  * @brief Get field attribute_id from event sdp_event_query_attribute_value
172  * @param Event packet
173  * @return attribute_id
174  * @note: btstack_type 2
175  */
176 static inline uint16_t sdp_event_query_attribute_value_get_attribute_id(const uint8_t * event){
177     return little_endian_read_16(event, 4);
178 }
179 
180 /**
181  * @brief Get field attribute_length from event sdp_event_query_attribute_value
182  * @param Event packet
183  * @return attribute_length
184  * @note: btstack_type L
185  */
186 static inline int sdp_event_query_attribute_value_get_attribute_length(const uint8_t * event){
187     return little_endian_read_16(event, 6);
188 }
189 
190 /**
191  * @brief Get field attribute_value from event sdp_event_query_attribute_value
192  * @param Event packet
193  * @return attribute_value
194  * @note: btstack_type V
195  */
196 static inline const uint8_t * sdp_event_query_attribute_value_get_attribute_value(const uint8_t * event){
197     return &event[8];
198 }
199 
200 /**
201  * @brief Get field total_count from event sdp_event_query_service_record_handle
202  * @param Event packet
203  * @return total_count
204  * @note: btstack_type 2
205  */
206 static inline uint16_t sdp_event_query_service_record_handle_get_total_count(const uint8_t * event){
207     return little_endian_read_16(event, 2);
208 }
209 
210 /**
211  * @brief Get field record_index from event sdp_event_query_service_record_handle
212  * @param Event packet
213  * @return record_index
214  * @note: btstack_type 2
215  */
216 static inline uint16_t sdp_event_query_service_record_handle_get_record_index(const uint8_t * event){
217     return little_endian_read_16(event, 4);
218 }
219 
220 /**
221  * @brief Get field record_handle from event sdp_event_query_service_record_handle
222  * @param Event packet
223  * @return record_handle
224  * @note: btstack_type 4
225  */
226 static inline uint32_t sdp_event_query_service_record_handle_get_record_handle(const uint8_t * event){
227     return little_endian_read_32(event, 6);
228 }
229 
230 /**
231  * @brief Get field handle from event sm_event_just_works_request
232  * @param Event packet
233  * @return handle
234  * @note: btstack_type H
235  */
236 static inline hci_con_handle_t sm_event_just_works_request_get_handle(const uint8_t * event){
237     return little_endian_read_16(event, 2);
238 }
239 
240 /**
241  * @brief Get field addr_type from event sm_event_just_works_request
242  * @param Event packet
243  * @return addr_type
244  * @note: btstack_type 1
245  */
246 static inline uint8_t sm_event_just_works_request_get_addr_type(const uint8_t * event){
247     return event[4];
248 }
249 
250 /**
251  * @brief Get field address from event sm_event_just_works_request
252  * @param Event packet
253  * @param Pointer to storage for address
254  * @note: btstack_type B
255  */
256 static inline void sm_event_just_works_request_get_address(const uint8_t * event, bd_addr_t address){
257     swap48(&event[5], address);
258 }
259 
260 /**
261  * @brief Get field handle from event sm_event_just_works_cancel
262  * @param Event packet
263  * @return handle
264  * @note: btstack_type H
265  */
266 static inline hci_con_handle_t sm_event_just_works_cancel_get_handle(const uint8_t * event){
267     return little_endian_read_16(event, 2);
268 }
269 
270 /**
271  * @brief Get field addr_type from event sm_event_just_works_cancel
272  * @param Event packet
273  * @return addr_type
274  * @note: btstack_type 1
275  */
276 static inline uint8_t sm_event_just_works_cancel_get_addr_type(const uint8_t * event){
277     return event[4];
278 }
279 
280 /**
281  * @brief Get field address from event sm_event_just_works_cancel
282  * @param Event packet
283  * @param Pointer to storage for address
284  * @note: btstack_type B
285  */
286 static inline void sm_event_just_works_cancel_get_address(const uint8_t * event, bd_addr_t address){
287     swap48(&event[5], address);
288 }
289 
290 /**
291  * @brief Get field handle from event sm_event_passkey_display_number
292  * @param Event packet
293  * @return handle
294  * @note: btstack_type H
295  */
296 static inline hci_con_handle_t sm_event_passkey_display_number_get_handle(const uint8_t * event){
297     return little_endian_read_16(event, 2);
298 }
299 
300 /**
301  * @brief Get field addr_type from event sm_event_passkey_display_number
302  * @param Event packet
303  * @return addr_type
304  * @note: btstack_type 1
305  */
306 static inline uint8_t sm_event_passkey_display_number_get_addr_type(const uint8_t * event){
307     return event[4];
308 }
309 
310 /**
311  * @brief Get field address from event sm_event_passkey_display_number
312  * @param Event packet
313  * @param Pointer to storage for address
314  * @note: btstack_type B
315  */
316 static inline void sm_event_passkey_display_number_get_address(const uint8_t * event, bd_addr_t address){
317     swap48(&event[5], address);
318 }
319 
320 /**
321  * @brief Get field passkey from event sm_event_passkey_display_number
322  * @param Event packet
323  * @return passkey
324  * @note: btstack_type 4
325  */
326 static inline uint32_t sm_event_passkey_display_number_get_passkey(const uint8_t * event){
327     return little_endian_read_32(event, 11);
328 }
329 
330 /**
331  * @brief Get field handle from event sm_event_passkey_display_cancel
332  * @param Event packet
333  * @return handle
334  * @note: btstack_type H
335  */
336 static inline hci_con_handle_t sm_event_passkey_display_cancel_get_handle(const uint8_t * event){
337     return little_endian_read_16(event, 2);
338 }
339 
340 /**
341  * @brief Get field addr_type from event sm_event_passkey_display_cancel
342  * @param Event packet
343  * @return addr_type
344  * @note: btstack_type 1
345  */
346 static inline uint8_t sm_event_passkey_display_cancel_get_addr_type(const uint8_t * event){
347     return event[4];
348 }
349 
350 /**
351  * @brief Get field address from event sm_event_passkey_display_cancel
352  * @param Event packet
353  * @param Pointer to storage for address
354  * @note: btstack_type B
355  */
356 static inline void sm_event_passkey_display_cancel_get_address(const uint8_t * event, bd_addr_t address){
357     swap48(&event[5], address);
358 }
359 
360 /**
361  * @brief Get field handle from event sm_event_passkey_input_number
362  * @param Event packet
363  * @return handle
364  * @note: btstack_type H
365  */
366 static inline hci_con_handle_t sm_event_passkey_input_number_get_handle(const uint8_t * event){
367     return little_endian_read_16(event, 2);
368 }
369 
370 /**
371  * @brief Get field addr_type from event sm_event_passkey_input_number
372  * @param Event packet
373  * @return addr_type
374  * @note: btstack_type 1
375  */
376 static inline uint8_t sm_event_passkey_input_number_get_addr_type(const uint8_t * event){
377     return event[4];
378 }
379 
380 /**
381  * @brief Get field address from event sm_event_passkey_input_number
382  * @param Event packet
383  * @param Pointer to storage for address
384  * @note: btstack_type B
385  */
386 static inline void sm_event_passkey_input_number_get_address(const uint8_t * event, bd_addr_t address){
387     swap48(&event[5], address);
388 }
389 
390 /**
391  * @brief Get field handle from event sm_event_passkey_input_cancel
392  * @param Event packet
393  * @return handle
394  * @note: btstack_type H
395  */
396 static inline hci_con_handle_t sm_event_passkey_input_cancel_get_handle(const uint8_t * event){
397     return little_endian_read_16(event, 2);
398 }
399 
400 /**
401  * @brief Get field addr_type from event sm_event_passkey_input_cancel
402  * @param Event packet
403  * @return addr_type
404  * @note: btstack_type 1
405  */
406 static inline uint8_t sm_event_passkey_input_cancel_get_addr_type(const uint8_t * event){
407     return event[4];
408 }
409 
410 /**
411  * @brief Get field address from event sm_event_passkey_input_cancel
412  * @param Event packet
413  * @param Pointer to storage for address
414  * @note: btstack_type B
415  */
416 static inline void sm_event_passkey_input_cancel_get_address(const uint8_t * event, bd_addr_t address){
417     swap48(&event[5], address);
418 }
419 
420 /**
421  * @brief Get field handle from event sm_event_identity_resolving_started
422  * @param Event packet
423  * @return handle
424  * @note: btstack_type H
425  */
426 static inline hci_con_handle_t sm_event_identity_resolving_started_get_handle(const uint8_t * event){
427     return little_endian_read_16(event, 2);
428 }
429 
430 /**
431  * @brief Get field addr_type from event sm_event_identity_resolving_started
432  * @param Event packet
433  * @return addr_type
434  * @note: btstack_type 1
435  */
436 static inline uint8_t sm_event_identity_resolving_started_get_addr_type(const uint8_t * event){
437     return event[4];
438 }
439 
440 /**
441  * @brief Get field address from event sm_event_identity_resolving_started
442  * @param Event packet
443  * @param Pointer to storage for address
444  * @note: btstack_type B
445  */
446 static inline void sm_event_identity_resolving_started_get_address(const uint8_t * event, bd_addr_t address){
447     swap48(&event[5], address);
448 }
449 
450 /**
451  * @brief Get field handle from event sm_event_identity_resolving_failed
452  * @param Event packet
453  * @return handle
454  * @note: btstack_type H
455  */
456 static inline hci_con_handle_t sm_event_identity_resolving_failed_get_handle(const uint8_t * event){
457     return little_endian_read_16(event, 2);
458 }
459 
460 /**
461  * @brief Get field addr_type from event sm_event_identity_resolving_failed
462  * @param Event packet
463  * @return addr_type
464  * @note: btstack_type 1
465  */
466 static inline uint8_t sm_event_identity_resolving_failed_get_addr_type(const uint8_t * event){
467     return event[4];
468 }
469 
470 /**
471  * @brief Get field address from event sm_event_identity_resolving_failed
472  * @param Event packet
473  * @param Pointer to storage for address
474  * @note: btstack_type B
475  */
476 static inline void sm_event_identity_resolving_failed_get_address(const uint8_t * event, bd_addr_t address){
477     swap48(&event[5], address);
478 }
479 
480 /**
481  * @brief Get field handle from event sm_event_identity_resolving_succeeded
482  * @param Event packet
483  * @return handle
484  * @note: btstack_type H
485  */
486 static inline hci_con_handle_t sm_event_identity_resolving_succeeded_get_handle(const uint8_t * event){
487     return little_endian_read_16(event, 2);
488 }
489 
490 /**
491  * @brief Get field addr_type from event sm_event_identity_resolving_succeeded
492  * @param Event packet
493  * @return addr_type
494  * @note: btstack_type 1
495  */
496 static inline uint8_t sm_event_identity_resolving_succeeded_get_addr_type(const uint8_t * event){
497     return event[4];
498 }
499 
500 /**
501  * @brief Get field address from event sm_event_identity_resolving_succeeded
502  * @param Event packet
503  * @param Pointer to storage for address
504  * @note: btstack_type B
505  */
506 static inline void sm_event_identity_resolving_succeeded_get_address(const uint8_t * event, bd_addr_t address){
507     swap48(&event[5], address);
508 }
509 
510 /**
511  * @brief Get field le_device_db_index from event sm_event_identity_resolving_succeeded
512  * @param Event packet
513  * @return le_device_db_index
514  * @note: btstack_type 2
515  */
516 static inline uint16_t sm_event_identity_resolving_succeeded_get_le_device_db_index(const uint8_t * event){
517     return little_endian_read_16(event, 11);
518 }
519 
520 /**
521  * @brief Get field handle from event sm_event_authorization_request
522  * @param Event packet
523  * @return handle
524  * @note: btstack_type H
525  */
526 static inline hci_con_handle_t sm_event_authorization_request_get_handle(const uint8_t * event){
527     return little_endian_read_16(event, 2);
528 }
529 
530 /**
531  * @brief Get field addr_type from event sm_event_authorization_request
532  * @param Event packet
533  * @return addr_type
534  * @note: btstack_type 1
535  */
536 static inline uint8_t sm_event_authorization_request_get_addr_type(const uint8_t * event){
537     return event[4];
538 }
539 
540 /**
541  * @brief Get field address from event sm_event_authorization_request
542  * @param Event packet
543  * @param Pointer to storage for address
544  * @note: btstack_type B
545  */
546 static inline void sm_event_authorization_request_get_address(const uint8_t * event, bd_addr_t address){
547     swap48(&event[5], address);
548 }
549 
550 /**
551  * @brief Get field handle from event sm_event_authorization_result
552  * @param Event packet
553  * @return handle
554  * @note: btstack_type H
555  */
556 static inline hci_con_handle_t sm_event_authorization_result_get_handle(const uint8_t * event){
557     return little_endian_read_16(event, 2);
558 }
559 
560 /**
561  * @brief Get field addr_type from event sm_event_authorization_result
562  * @param Event packet
563  * @return addr_type
564  * @note: btstack_type 1
565  */
566 static inline uint8_t sm_event_authorization_result_get_addr_type(const uint8_t * event){
567     return event[4];
568 }
569 
570 /**
571  * @brief Get field address from event sm_event_authorization_result
572  * @param Event packet
573  * @param Pointer to storage for address
574  * @note: btstack_type B
575  */
576 static inline void sm_event_authorization_result_get_address(const uint8_t * event, bd_addr_t address){
577     swap48(&event[5], address);
578 }
579 
580 /**
581  * @brief Get field authorization_result from event sm_event_authorization_result
582  * @param Event packet
583  * @return authorization_result
584  * @note: btstack_type 1
585  */
586 static inline uint8_t sm_event_authorization_result_get_authorization_result(const uint8_t * event){
587     return event[11];
588 }
589 
590 /**
591  * @brief Get field handle from event ancs_event_client_connected
592  * @param Event packet
593  * @return handle
594  * @note: btstack_type H
595  */
596 static inline hci_con_handle_t ancs_event_client_connected_get_handle(const uint8_t * event){
597     return little_endian_read_16(event, 2);
598 }
599 
600 /**
601  * @brief Get field handle from event ancs_event_client_notification
602  * @param Event packet
603  * @return handle
604  * @note: btstack_type H
605  */
606 static inline hci_con_handle_t ancs_event_client_notification_get_handle(const uint8_t * event){
607     return little_endian_read_16(event, 2);
608 }
609 
610 /**
611  * @brief Get field attribute_id from event ancs_event_client_notification
612  * @param Event packet
613  * @return attribute_id
614  * @note: btstack_type 2
615  */
616 static inline uint16_t ancs_event_client_notification_get_attribute_id(const uint8_t * event){
617     return little_endian_read_16(event, 4);
618 }
619 
620 /**
621  * @brief Get field text from event ancs_event_client_notification
622  * @param Event packet
623  * @return text
624  * @note: btstack_type T
625  */
626 static inline const char * ancs_event_client_notification_get_text(const uint8_t * event){
627     return (const char *) &event[6];
628 }
629 
630 /**
631  * @brief Get field handle from event ancs_event_client_disconnected
632  * @param Event packet
633  * @return handle
634  * @note: btstack_type H
635  */
636 static inline hci_con_handle_t ancs_event_client_disconnected_get_handle(const uint8_t * event){
637     return little_endian_read_16(event, 2);
638 }
639 
640 
641 /* API_END */
642 
643 #if defined __cplusplus
644 }
645 #endif
646 
647 #endif // __BTSTACK_EVENT_H
648