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