1 /* 2 * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef __BTC_GAP_BT_H__ 8 #define __BTC_GAP_BT_H__ 9 10 #include "common/bt_target.h" 11 #include "common/bt_defs.h" 12 #include "esp_bt_defs.h" 13 #include "esp_gap_bt_api.h" 14 #include "btc/btc_task.h" 15 #include "bta/utl.h" 16 17 #if (BTC_GAP_BT_INCLUDED == TRUE) 18 typedef enum { 19 BTC_GAP_BT_SEARCH_DEVICES_EVT = 0, 20 BTC_GAP_BT_SEARCH_SERVICES_EVT, 21 BTC_GAP_BT_SEARCH_SERVICE_RECORD_EVT, 22 BTC_GAP_BT_AUTH_CMPL_EVT, 23 BTC_GAP_BT_PIN_REQ_EVT, 24 BTC_GAP_BT_CFM_REQ_EVT, 25 BTC_GAP_BT_KEY_NOTIF_EVT, 26 BTC_GAP_BT_KEY_REQ_EVT, 27 BTC_GAP_BT_READ_RSSI_DELTA_EVT, 28 BTC_GAP_BT_CONFIG_EIR_DATA_EVT, 29 BTC_GAP_BT_SET_AFH_CHANNELS_EVT, 30 BTC_GAP_BT_READ_REMOTE_NAME_EVT, 31 BTC_GAP_BT_MODE_CHG_EVT, 32 BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT, 33 BTC_GAP_BT_QOS_EVT, 34 }btc_gap_bt_evt_t; 35 36 typedef enum { 37 BTC_GAP_BT_ACT_SET_SCAN_MODE = 0, 38 BTC_GAP_BT_ACT_START_DISCOVERY, 39 BTC_GAP_BT_ACT_CANCEL_DISCOVERY, 40 BTC_GAP_BT_ACT_GET_REMOTE_SERVICES, 41 BTC_GAP_BT_ACT_GET_REMOTE_SERVICE_RECORD, 42 BTC_GAP_BT_ACT_SET_COD, 43 BTC_GAP_BT_ACT_READ_RSSI_DELTA, 44 BTC_GAP_BT_ACT_REMOVE_BOND_DEVICE, 45 BTC_GAP_BT_ACT_SET_PIN_TYPE, 46 BTC_GAP_BT_ACT_PIN_REPLY, 47 BTC_GAP_BT_ACT_SET_SECURITY_PARAM, 48 BTC_GAP_BT_ACT_PASSKEY_REPLY, 49 BTC_GAP_BT_ACT_CONFIRM_REPLY, 50 BTC_GAP_BT_ACT_CONFIG_EIR, 51 BTC_GAP_BT_ACT_SET_AFH_CHANNELS, 52 BTC_GAP_BT_ACT_READ_REMOTE_NAME, 53 BTC_GAP_BT_ACT_SET_QOS, 54 } btc_gap_bt_act_t; 55 56 /* btc_bt_gap_args_t */ 57 typedef union { 58 // BTC_BT_GAP_ACT_SET_SCAN_MODE, 59 struct set_bt_scan_mode_args { 60 esp_bt_connection_mode_t c_mode; 61 esp_bt_discovery_mode_t d_mode; 62 } set_scan_mode; 63 64 // BTC_GAP_BT_ACT_START_DISCOVERY 65 struct start_disc_args { 66 esp_bt_inq_mode_t mode; 67 uint8_t inq_len; 68 uint8_t num_rsps; 69 } start_disc; 70 71 // BTC_GAP_BT_ACT_GET_REMOTE_SERVICES 72 bt_bdaddr_t bda; 73 74 // BTC_GAP_BT_ACT_GET_REMOTE_SERVICE_RECORD 75 struct get_rmt_srv_rcd_args { 76 bt_bdaddr_t bda; 77 esp_bt_uuid_t uuid; 78 } get_rmt_srv_rcd; 79 80 // BTC_GAP_BT_ACT_SET_COD 81 struct set_cod_args { 82 esp_bt_cod_t cod; 83 esp_bt_cod_mode_t mode; 84 } set_cod; 85 86 //BTC_GAP_BT_ACT_READ_RSSI_DELTA, 87 struct bt_read_rssi_delta_args { 88 bt_bdaddr_t bda; 89 } read_rssi_delta; 90 91 // BTC_GAP_BT_ACT_REMOVE_BOND_DEVICE 92 struct rm_bond_device_args { 93 bt_bdaddr_t bda; 94 } rm_bond_device; 95 96 // BTC_GAP_BT_ACT_SET_PIN_TYPE 97 struct set_pin_type_args { 98 esp_bt_pin_type_t pin_type; 99 uint8_t pin_code_len; 100 esp_bt_pin_code_t pin_code; 101 } set_pin_type; 102 103 // BTC_GAP_BT_ACT_PIN_REPLY 104 struct pin_reply_args { 105 bt_bdaddr_t bda; 106 bool accept; 107 uint8_t pin_code_len; 108 esp_bt_pin_code_t pin_code; 109 } pin_reply; 110 111 // BTC_GAP_BT_ACT_SET_SECURITY_PARAM 112 struct set_sec_param_args { 113 esp_bt_sp_param_t param_type; 114 uint8_t len; 115 uint8_t *value; 116 } set_security_param; 117 118 // BTC_GAP_BT_ACT_PASSKEY_REPLY 119 struct passkey_reply_args { 120 bt_bdaddr_t bda; 121 bool accept; 122 uint32_t passkey; 123 } passkey_reply; 124 125 // BTC_GAP_BT_ACT_CONFIRM_REPLY 126 struct confirm_reply_args { 127 bt_bdaddr_t bda; 128 bool accept; 129 } confirm_reply; 130 131 // BTC_GAP_BT_ACT_CONFIG_EIR 132 struct config_eir_args { 133 esp_bt_eir_data_t eir_data; 134 } config_eir; 135 136 // BTC_GAP_BT_ACT_SET_AFH_CHANNELS 137 struct set_afh_channels_args { 138 esp_bt_gap_afh_channels channels; 139 } set_afh_channels; 140 141 // BTC_GAP_BT_ACT_READ_REMOTE_NAME 142 bt_bdaddr_t rmt_name_bda; 143 144 // BTC_GAP_BT_ACT_SET_QOS 145 struct set_qos_args { 146 bt_bdaddr_t bda; 147 uint32_t t_poll; 148 } set_qos; 149 150 } btc_gap_bt_args_t; 151 152 void btc_gap_bt_call_handler(btc_msg_t *msg); 153 void btc_gap_bt_cb_handler(btc_msg_t *msg); 154 void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); 155 void btc_gap_bt_arg_deep_free(btc_msg_t *msg); 156 void btc_gap_bt_busy_level_updated(uint8_t bl_flags); 157 158 esp_err_t btc_gap_bt_get_cod(esp_bt_cod_t *cod); 159 #endif /* #if BTC_GAP_BT_INCLUDED */ 160 161 #endif /* __BTC_GAP_BT_H__ */ 162