17d902a1fSMatthias Ringwald /* 27d902a1fSMatthias Ringwald * Copyright (C) 2020 BlueKitchen GmbH 37d902a1fSMatthias Ringwald * 47d902a1fSMatthias Ringwald * Redistribution and use in source and binary forms, with or without 57d902a1fSMatthias Ringwald * modification, are permitted provided that the following conditions 67d902a1fSMatthias Ringwald * are met: 77d902a1fSMatthias Ringwald * 87d902a1fSMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 97d902a1fSMatthias Ringwald * notice, this list of conditions and the following disclaimer. 107d902a1fSMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 117d902a1fSMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 127d902a1fSMatthias Ringwald * documentation and/or other materials provided with the distribution. 137d902a1fSMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 147d902a1fSMatthias Ringwald * contributors may be used to endorse or promote products derived 157d902a1fSMatthias Ringwald * from this software without specific prior written permission. 167d902a1fSMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 177d902a1fSMatthias Ringwald * personal benefit and not for any commercial purpose or for 187d902a1fSMatthias Ringwald * monetary gain. 197d902a1fSMatthias Ringwald * 207d902a1fSMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 217d902a1fSMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 227d902a1fSMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 237d902a1fSMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 247d902a1fSMatthias Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 257d902a1fSMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 267d902a1fSMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 277d902a1fSMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 287d902a1fSMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 297d902a1fSMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 307d902a1fSMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 317d902a1fSMatthias Ringwald * SUCH DAMAGE. 327d902a1fSMatthias Ringwald * 337d902a1fSMatthias Ringwald * Please inquire about commercial licensing options at 347d902a1fSMatthias Ringwald * [email protected] 357d902a1fSMatthias Ringwald * 367d902a1fSMatthias Ringwald */ 377d902a1fSMatthias Ringwald 387d902a1fSMatthias Ringwald /* 397d902a1fSMatthias Ringwald * hci_event.h 407d902a1fSMatthias Ringwald */ 417d902a1fSMatthias Ringwald 427d902a1fSMatthias Ringwald #ifndef HCI_EVENT_H 437d902a1fSMatthias Ringwald #define HCI_EVENT_H 447d902a1fSMatthias Ringwald 457d902a1fSMatthias Ringwald #include "bluetooth.h" 467d902a1fSMatthias Ringwald 477d902a1fSMatthias Ringwald #include <stdint.h> 487d902a1fSMatthias Ringwald #include <stdarg.h> 497d902a1fSMatthias Ringwald 507d902a1fSMatthias Ringwald #if defined __cplusplus 517d902a1fSMatthias Ringwald extern "C" { 527d902a1fSMatthias Ringwald #endif 537d902a1fSMatthias Ringwald 547d902a1fSMatthias Ringwald /** 557d902a1fSMatthias Ringwald * compact HCI Event packet description 567d902a1fSMatthias Ringwald * no subevent_code field -> subevnt_code == 0 577d902a1fSMatthias Ringwald */ 587d902a1fSMatthias Ringwald typedef struct { 597d902a1fSMatthias Ringwald uint8_t event_code; 607d902a1fSMatthias Ringwald uint8_t subevent_code; 617d902a1fSMatthias Ringwald const char *format; 627d902a1fSMatthias Ringwald } hci_event_t; 637d902a1fSMatthias Ringwald 647d902a1fSMatthias Ringwald /** 657d902a1fSMatthias Ringwald * construct HCI Event based on template 667d902a1fSMatthias Ringwald * 677d902a1fSMatthias Ringwald * Format: 687d902a1fSMatthias Ringwald * 1,2,3,4: one to four byte value 697d902a1fSMatthias Ringwald * H: HCI connection handle 707d902a1fSMatthias Ringwald * B: Bluetooth Baseband Address (BD_ADDR) 717d902a1fSMatthias Ringwald * D: 8 byte data block 727d902a1fSMatthias Ringwald * P: 16 byte data block. 737d902a1fSMatthias Ringwald * Q: 32 byte data block, e.g. for X and Y coordinates of P-256 public key 747d902a1fSMatthias Ringwald * J: 1-byte length of following variable-length data blob 'V', length is included in packet 757d902a1fSMatthias Ringwald * K: 1-byte length of following variable-length data blob 'V', length is not included in packet 767d902a1fSMatthias Ringwald * V: variable-length data blob of len provided in 'J' field 777d902a1fSMatthias Ringwald */ 78*c70b3b48SMatthias Ringwald uint16_t hci_event_create_from_template_and_arglist(uint8_t *hci_buffer, uint16_t buffer_size, const hci_event_t *event, va_list argptr); 797d902a1fSMatthias Ringwald 807d902a1fSMatthias Ringwald 81*c70b3b48SMatthias Ringwald uint16_t hci_event_create_from_template_and_arguments(uint8_t *hci_buffer, uint16_t buffer_size, const hci_event_t *event, ...); 827d902a1fSMatthias Ringwald 837d902a1fSMatthias Ringwald /* LE Events */ 847d902a1fSMatthias Ringwald extern const hci_event_t hci_event_hardware_error; 857d902a1fSMatthias Ringwald extern const hci_event_t hci_event_command_complete; 867d902a1fSMatthias Ringwald extern const hci_event_t hci_event_disconnection_complete; 877d902a1fSMatthias Ringwald extern const hci_event_t hci_event_number_of_completed_packets_1; 887d902a1fSMatthias Ringwald extern const hci_event_t hci_event_transport_packet_sent; 897d902a1fSMatthias Ringwald 907d902a1fSMatthias Ringwald /* LE Subevents */ 917d902a1fSMatthias Ringwald extern const hci_event_t hci_subevent_le_connection_complete; 927d902a1fSMatthias Ringwald 937d902a1fSMatthias Ringwald 947d902a1fSMatthias Ringwald #if defined __cplusplus 957d902a1fSMatthias Ringwald } 967d902a1fSMatthias Ringwald #endif 977d902a1fSMatthias Ringwald 987d902a1fSMatthias Ringwald #endif // HCI_EVENT_H 99