1458bf4e8S[email protected] /* 2a0c35809S[email protected] * Copyright (C) 2014 BlueKitchen GmbH 3458bf4e8S[email protected] * 4458bf4e8S[email protected] * Redistribution and use in source and binary forms, with or without 5458bf4e8S[email protected] * modification, are permitted provided that the following conditions 6458bf4e8S[email protected] * are met: 7458bf4e8S[email protected] * 8458bf4e8S[email protected] * 1. Redistributions of source code must retain the above copyright 9458bf4e8S[email protected] * notice, this list of conditions and the following disclaimer. 10458bf4e8S[email protected] * 2. Redistributions in binary form must reproduce the above copyright 11458bf4e8S[email protected] * notice, this list of conditions and the following disclaimer in the 12458bf4e8S[email protected] * documentation and/or other materials provided with the distribution. 13458bf4e8S[email protected] * 3. Neither the name of the copyright holders nor the names of 14458bf4e8S[email protected] * contributors may be used to endorse or promote products derived 15458bf4e8S[email protected] * from this software without specific prior written permission. 16458bf4e8S[email protected] * 4. Any redistribution, use, or modification is done solely for 17458bf4e8S[email protected] * personal benefit and not for any commercial purpose or for 18458bf4e8S[email protected] * monetary gain. 19458bf4e8S[email protected] * 20a0c35809S[email protected] * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21458bf4e8S[email protected] * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22458bf4e8S[email protected] * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23458bf4e8S[email protected] * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24458bf4e8S[email protected] * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25458bf4e8S[email protected] * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26458bf4e8S[email protected] * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27458bf4e8S[email protected] * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28458bf4e8S[email protected] * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29458bf4e8S[email protected] * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30458bf4e8S[email protected] * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31458bf4e8S[email protected] * SUCH DAMAGE. 32458bf4e8S[email protected] * 33a0c35809S[email protected] * Please inquire about commercial licensing options at 34a0c35809S[email protected] * [email protected] 35458bf4e8S[email protected] * 36458bf4e8S[email protected] */ 37458bf4e8S[email protected] 38f471afd8S[email protected] #ifndef __GAP_H 39f471afd8S[email protected] #define __GAP_H 40458bf4e8S[email protected] 41458bf4e8S[email protected] #if defined __cplusplus 42458bf4e8S[email protected] extern "C" { 43458bf4e8S[email protected] #endif 44458bf4e8S[email protected] 45cb230b9dS[email protected] typedef enum { 46cb230b9dS[email protected] 47cb230b9dS[email protected] // MITM protection not required 48cb230b9dS[email protected] // No encryption required 49cb230b9dS[email protected] // No user interaction required 50cb230b9dS[email protected] LEVEL_0 = 0, 51cb230b9dS[email protected] 52cb230b9dS[email protected] // MITM protection not required 53cb230b9dS[email protected] // No encryption required 54cb230b9dS[email protected] // Minimal user interaction desired 55cb230b9dS[email protected] LEVEL_1, 56cb230b9dS[email protected] 57cb230b9dS[email protected] // MITM protection not required 58cb230b9dS[email protected] // Encryption required 59cb230b9dS[email protected] LEVEL_2, 60cb230b9dS[email protected] 61cb230b9dS[email protected] // MITM protection required 62cb230b9dS[email protected] // Encryption required 63cb230b9dS[email protected] // User interaction acceptable 64cb230b9dS[email protected] LEVEL_3, 65cb230b9dS[email protected] 66cb230b9dS[email protected] // MITM protection required 67cb230b9dS[email protected] // Encryption required 683c68dfa9S[email protected] // 128-bit equivalent strength for link and encryption keys required (P-192 is not enough) 69cb230b9dS[email protected] // User interaction acceptable 70cb230b9dS[email protected] LEVEL_4, 71cb230b9dS[email protected] } gap_security_level_t; 72cb230b9dS[email protected] 7334f9eab8S[email protected] typedef enum { 7434f9eab8S[email protected] GAP_SECURITY_NONE, 7534f9eab8S[email protected] GAP_SECUIRTY_ENCRYPTED, // SSP: JUST WORKS 7634f9eab8S[email protected] GAP_SECURITY_AUTHENTICATED, // SSP: numeric comparison, passkey, OOB 7734f9eab8S[email protected] // GAP_SECURITY_AUTHORIZED 783c68dfa9S[email protected] } gap_security_state; 7934f9eab8S[email protected] 80*a1bf5ae7SMatthias Ringwald typedef enum { 81*a1bf5ae7SMatthias Ringwald GAP_CONNECTION_INVALID, 82*a1bf5ae7SMatthias Ringwald GAP_CONNECTION_ACL, 83*a1bf5ae7SMatthias Ringwald GAP_CONNECTION_SCO, 84*a1bf5ae7SMatthias Ringwald GAP_CONNECTION_LE 85*a1bf5ae7SMatthias Ringwald } gap_connection_type_t; 86*a1bf5ae7SMatthias Ringwald 873de95307SMilanka Ringwald /* API_START */ 883de95307SMilanka Ringwald 89458bf4e8S[email protected] /** 903de95307SMilanka Ringwald * @brief Enable/disable bonding. Default is enabled. 913de95307SMilanka Ringwald * @param enabled 92458bf4e8S[email protected] */ 93458bf4e8S[email protected] void gap_set_bondable_mode(int enabled); 9434d2123cS[email protected] 95ad83dc6aS[email protected] /** 96671d15e6SMatthias Ringwald * @brief Get bondable mode. 97671d15e6SMatthias Ringwald * @return 1 if bondable 98671d15e6SMatthias Ringwald */ 99671d15e6SMatthias Ringwald int gap_get_bondable_mode(void); 100671d15e6SMatthias Ringwald 101671d15e6SMatthias Ringwald /** 1023de95307SMilanka Ringwald * @brief Start dedicated bonding with device. Disconnect after bonding. 103ad83dc6aS[email protected] * @param device 104ad83dc6aS[email protected] * @param request MITM protection 1053de95307SMilanka Ringwald * @return error, if max num acl connections active 106ad83dc6aS[email protected] * @result GAP_DEDICATED_BONDING_COMPLETE 107ad83dc6aS[email protected] */ 108ad83dc6aS[email protected] int gap_dedicated_bonding(bd_addr_t device, int mitm_protection_required); 109ad83dc6aS[email protected] 11034d2123cS[email protected] gap_security_level_t gap_security_level_for_link_key_type(link_key_type_t link_key_type); 111ad671560S[email protected] gap_security_level_t gap_security_level(hci_con_handle_t con_handle); 11234d2123cS[email protected] 113ad671560S[email protected] void gap_request_security_level(hci_con_handle_t con_handle, gap_security_level_t level); 114106d6d11S[email protected] int gap_mitm_protection_required_for_security_level(gap_security_level_t level); 115458bf4e8S[email protected] 1163de95307SMilanka Ringwald /** 1173de95307SMilanka Ringwald * @brief Sets local name. 1188e618f72S[email protected] * @note has to be done before stack starts up 1198e618f72S[email protected] * @param name is not copied, make sure memory is accessible during stack startup 1208e618f72S[email protected] */ 1218e618f72S[email protected] void gap_set_local_name(const char * local_name); 1223de95307SMilanka Ringwald /* API_END*/ 1238e618f72S[email protected] 124*a1bf5ae7SMatthias Ringwald /** 125*a1bf5ae7SMatthias Ringwald * @brief Get connection type 126*a1bf5ae7SMatthias Ringwald * @param con_handle 127*a1bf5ae7SMatthias Ringwald * @result connection_type 128*a1bf5ae7SMatthias Ringwald */ 129*a1bf5ae7SMatthias Ringwald gap_connection_type_t gap_get_connection_type(hci_con_handle_t connection_handle); 130*a1bf5ae7SMatthias Ringwald 131458bf4e8S[email protected] #if defined __cplusplus 132458bf4e8S[email protected] } 133458bf4e8S[email protected] #endif 134458bf4e8S[email protected] 135f471afd8S[email protected] #endif // __GAP_H 136