1*7d902a1fSMatthias Ringwald /* 2*7d902a1fSMatthias Ringwald * Copyright (C) 2020 BlueKitchen GmbH 3*7d902a1fSMatthias Ringwald * 4*7d902a1fSMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5*7d902a1fSMatthias Ringwald * modification, are permitted provided that the following conditions 6*7d902a1fSMatthias Ringwald * are met: 7*7d902a1fSMatthias Ringwald * 8*7d902a1fSMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9*7d902a1fSMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10*7d902a1fSMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11*7d902a1fSMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12*7d902a1fSMatthias Ringwald * documentation and/or other materials provided with the distribution. 13*7d902a1fSMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14*7d902a1fSMatthias Ringwald * contributors may be used to endorse or promote products derived 15*7d902a1fSMatthias Ringwald * from this software without specific prior written permission. 16*7d902a1fSMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 17*7d902a1fSMatthias Ringwald * personal benefit and not for any commercial purpose or for 18*7d902a1fSMatthias Ringwald * monetary gain. 19*7d902a1fSMatthias Ringwald * 20*7d902a1fSMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21*7d902a1fSMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22*7d902a1fSMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23*7d902a1fSMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 24*7d902a1fSMatthias Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25*7d902a1fSMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26*7d902a1fSMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27*7d902a1fSMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28*7d902a1fSMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29*7d902a1fSMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30*7d902a1fSMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31*7d902a1fSMatthias Ringwald * SUCH DAMAGE. 32*7d902a1fSMatthias Ringwald * 33*7d902a1fSMatthias Ringwald * Please inquire about commercial licensing options at 34*7d902a1fSMatthias Ringwald * [email protected] 35*7d902a1fSMatthias Ringwald * 36*7d902a1fSMatthias Ringwald */ 37*7d902a1fSMatthias Ringwald 38*7d902a1fSMatthias Ringwald /* 39*7d902a1fSMatthias Ringwald * hci_event.h 40*7d902a1fSMatthias Ringwald */ 41*7d902a1fSMatthias Ringwald 42*7d902a1fSMatthias Ringwald #ifndef HCI_EVENT_H 43*7d902a1fSMatthias Ringwald #define HCI_EVENT_H 44*7d902a1fSMatthias Ringwald 45*7d902a1fSMatthias Ringwald #include "bluetooth.h" 46*7d902a1fSMatthias Ringwald 47*7d902a1fSMatthias Ringwald #include <stdint.h> 48*7d902a1fSMatthias Ringwald #include <stdarg.h> 49*7d902a1fSMatthias Ringwald 50*7d902a1fSMatthias Ringwald #if defined __cplusplus 51*7d902a1fSMatthias Ringwald extern "C" { 52*7d902a1fSMatthias Ringwald #endif 53*7d902a1fSMatthias Ringwald 54*7d902a1fSMatthias Ringwald /** 55*7d902a1fSMatthias Ringwald * compact HCI Event packet description 56*7d902a1fSMatthias Ringwald * no subevent_code field -> subevnt_code == 0 57*7d902a1fSMatthias Ringwald */ 58*7d902a1fSMatthias Ringwald typedef struct { 59*7d902a1fSMatthias Ringwald uint8_t event_code; 60*7d902a1fSMatthias Ringwald uint8_t subevent_code; 61*7d902a1fSMatthias Ringwald const char *format; 62*7d902a1fSMatthias Ringwald } hci_event_t; 63*7d902a1fSMatthias Ringwald 64*7d902a1fSMatthias Ringwald /** 65*7d902a1fSMatthias Ringwald * construct HCI Event based on template 66*7d902a1fSMatthias Ringwald * 67*7d902a1fSMatthias Ringwald * Format: 68*7d902a1fSMatthias Ringwald * 1,2,3,4: one to four byte value 69*7d902a1fSMatthias Ringwald * H: HCI connection handle 70*7d902a1fSMatthias Ringwald * B: Bluetooth Baseband Address (BD_ADDR) 71*7d902a1fSMatthias Ringwald * D: 8 byte data block 72*7d902a1fSMatthias Ringwald * P: 16 byte data block. 73*7d902a1fSMatthias Ringwald * Q: 32 byte data block, e.g. for X and Y coordinates of P-256 public key 74*7d902a1fSMatthias Ringwald * J: 1-byte length of following variable-length data blob 'V', length is included in packet 75*7d902a1fSMatthias Ringwald * K: 1-byte length of following variable-length data blob 'V', length is not included in packet 76*7d902a1fSMatthias Ringwald * V: variable-length data blob of len provided in 'J' field 77*7d902a1fSMatthias Ringwald */ 78*7d902a1fSMatthias Ringwald uint16_t hci_event_create_from_template_and_arglist(uint8_t *hci_buffer, const hci_event_t *event, va_list argptr); 79*7d902a1fSMatthias Ringwald 80*7d902a1fSMatthias Ringwald 81*7d902a1fSMatthias Ringwald uint16_t hci_event_create_from_template_and_arguments(uint8_t *hci_buffer, const hci_event_t *event, ...); 82*7d902a1fSMatthias Ringwald 83*7d902a1fSMatthias Ringwald /* LE Events */ 84*7d902a1fSMatthias Ringwald extern const hci_event_t hci_event_hardware_error; 85*7d902a1fSMatthias Ringwald extern const hci_event_t hci_event_command_complete; 86*7d902a1fSMatthias Ringwald extern const hci_event_t hci_event_disconnection_complete; 87*7d902a1fSMatthias Ringwald extern const hci_event_t hci_event_number_of_completed_packets_1; 88*7d902a1fSMatthias Ringwald extern const hci_event_t hci_event_transport_packet_sent; 89*7d902a1fSMatthias Ringwald 90*7d902a1fSMatthias Ringwald /* LE Subevents */ 91*7d902a1fSMatthias Ringwald extern const hci_event_t hci_subevent_le_connection_complete; 92*7d902a1fSMatthias Ringwald 93*7d902a1fSMatthias Ringwald 94*7d902a1fSMatthias Ringwald #if defined __cplusplus 95*7d902a1fSMatthias Ringwald } 96*7d902a1fSMatthias Ringwald #endif 97*7d902a1fSMatthias Ringwald 98*7d902a1fSMatthias Ringwald #endif // HCI_EVENT_H 99