From fed772641ae560b5ae6fe97f4c77b697869f1969 Mon Sep 17 00:00:00 2001 From: zhiweijian Date: Wed, 21 Nov 2018 15:45:48 +0800 Subject: [PATCH] Component/bt: add update duplicate scan exceptional list APIs --- components/bt/bluedroid/api/esp_gap_ble_api.c | 63 +++++++++++++++++ .../api/include/api/esp_gap_ble_api.h | 69 +++++++++++++++++++ components/bt/bluedroid/bta/dm/bta_dm_act.c | 16 +++++ components/bt/bluedroid/bta/dm/bta_dm_api.c | 28 ++++++++ components/bt/bluedroid/bta/dm/bta_dm_main.c | 1 + .../bt/bluedroid/bta/dm/include/bta_dm_int.h | 12 +++- .../bt/bluedroid/bta/include/bta/bta_api.h | 20 ++++++ .../btc/profile/std/gap/btc_gap_ble.c | 35 ++++++++++ .../btc/profile/std/include/btc_gap_ble.h | 7 ++ .../bt/bluedroid/stack/btm/btm_ble_gap.c | 46 +++++++++++++ .../bt/bluedroid/stack/btm/btm_devctl.c | 15 ++++ .../bluedroid/stack/btm/include/btm_ble_int.h | 4 ++ .../bluedroid/stack/include/stack/bt_types.h | 18 +++++ .../stack/include/stack/btm_ble_api.h | 17 +++++ components/bt/lib | 2 +- 15 files changed, 351 insertions(+), 2 deletions(-) diff --git a/components/bt/bluedroid/api/esp_gap_ble_api.c b/components/bt/bluedroid/api/esp_gap_ble_api.c index 9c444bb13..e1866aa48 100644 --- a/components/bt/bluedroid/api/esp_gap_ble_api.c +++ b/components/bt/bluedroid/api/esp_gap_ble_api.c @@ -449,6 +449,69 @@ esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_d } +esp_err_t esp_ble_gap_add_duplicate_scan_exceptional_device(esp_ble_duplicate_exceptional_info_type_t type, esp_duplicate_info_t device_info) +{ + btc_msg_t msg; + btc_ble_gap_args_t arg; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + if (!device_info){ + return ESP_ERR_INVALID_SIZE; + } + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST; + arg.update_duplicate_exceptional_list.subcode = ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_ADD; + arg.update_duplicate_exceptional_list.info_type = type; + memcpy(arg.update_duplicate_exceptional_list.device_info, device_info, sizeof(esp_bd_addr_t)); + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + +esp_err_t esp_ble_gap_remove_duplicate_scan_exceptional_device(esp_ble_duplicate_exceptional_info_type_t type, esp_duplicate_info_t device_info) +{ + btc_msg_t msg; + btc_ble_gap_args_t arg; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + if (!device_info){ + return ESP_ERR_INVALID_SIZE; + } + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST; + arg.update_duplicate_exceptional_list.subcode = ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_REMOVE; + arg.update_duplicate_exceptional_list.info_type = type; + memcpy(arg.update_duplicate_exceptional_list.device_info, device_info, sizeof(esp_bd_addr_t)); + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + +esp_err_t esp_ble_gap_clean_duplicate_scan_exceptional_list(esp_duplicate_scan_exceptional_list_type_t list_type) +{ + btc_msg_t msg; + btc_ble_gap_args_t arg; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST; + arg.update_duplicate_exceptional_list.subcode = ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_CLEAN; + arg.update_duplicate_exceptional_list.info_type = list_type; + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + #if (SMP_INCLUDED == TRUE) esp_err_t esp_ble_gap_set_security_param(esp_ble_sm_param_t param_type, void *value, uint8_t len) diff --git a/components/bt/bluedroid/api/include/api/esp_gap_ble_api.h b/components/bt/bluedroid/api/include/api/esp_gap_ble_api.h index 76d74473b..a346f8e8e 100644 --- a/components/bt/bluedroid/api/include/api/esp_gap_ble_api.h +++ b/components/bt/bluedroid/api/include/api/esp_gap_ble_api.h @@ -161,6 +161,7 @@ typedef enum { ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT, /*!< When get the bond device list complete, the event comes */ ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT, /*!< When read the rssi complete, the event comes */ ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT, /*!< When add or remove whitelist complete, the event comes */ + ESP_GAP_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_COMPLETE_EVT, /*!< When update duplicate exceptional list complete, the event comes */ ESP_GAP_BLE_EVT_MAX, } esp_gap_ble_cb_event_t; /// This is the old name, just for backwards compatibility @@ -571,6 +572,28 @@ typedef enum{ ESP_BLE_WHITELIST_REMOVE = 0X00, /*!< remove mac from whitelist */ ESP_BLE_WHITELIST_ADD = 0X01, /*!< add address to whitelist */ }esp_ble_wl_opration_t; + +typedef enum { + ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_ADD = 0, /*!< Add device info into duplicate scan exceptional list */ + ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_REMOVE, /*!< Remove device info from duplicate scan exceptional list */ + ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_CLEAN, /*!< Clean duplicate scan exceptional list */ +} esp_bt_duplicate_exceptional_subcode_type_t; + +#define BLE_BIT(n) (1UL<<(n)) + +typedef enum { + ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_ADV_ADDR = 0, /*!< BLE advertising address , device info will be added into ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ADDR_LIST */ + ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_LINK_ID, /*!< BLE mesh link ID, it is for BLE mesh, device info will be added into ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_LINK_ID_LIST */ +} esp_ble_duplicate_exceptional_info_type_t; + +typedef enum { + ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ADDR_LIST = BLE_BIT(0), /*!< duplicate scan exceptional addr list */ + ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_LINK_ID_LIST = BLE_BIT(1), /*!< duplicate scan exceptional mesh link ID list */ + ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ALL_LIST = (BLE_BIT(0) | BLE_BIT(1)), /*!< duplicate scan exceptional all list */ +} esp_duplicate_scan_exceptional_list_type_t; + +typedef uint8_t esp_duplicate_info_t[ESP_BD_ADDR_LEN]; + /** * @brief Gap callback parameters union */ @@ -717,6 +740,15 @@ typedef union { esp_bt_status_t status; /*!< Indicate the add or remove whitelist operation success status */ esp_ble_wl_opration_t wl_opration; /*!< The value is ESP_BLE_WHITELIST_ADD if add address to whitelist operation success, ESP_BLE_WHITELIST_REMOVE if remove address from the whitelist operation success */ } update_whitelist_cmpl; /*!< Event parameter of ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT */ + /** + * @brief ESP_GAP_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_COMPLETE_EVT + */ + struct ble_update_duplicate_exceptional_list_cmpl_evt_param { + esp_bt_status_t status; /*!< Indicate update duplicate scan exceptional list operation success status */ + uint8_t subcode; /*!< Define in esp_bt_duplicate_exceptional_subcode_type_t */ + uint16_t length; /*!< The length of device_info */ + esp_duplicate_info_t device_info; /*!< device information, when subcode is ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_CLEAN, the value is invalid */ + } update_duplicate_exceptional_list_cmpl; /*!< Event parameter of ESP_GAP_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_COMPLETE_EVT */ } esp_ble_gap_cb_param_t; /** @@ -1009,6 +1041,43 @@ esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_d */ esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr); +/** + * @brief This function is called to add a device info into the duplicate scan exceptional list. + * + * + * @param[in] type: device info type, it is defined in esp_ble_duplicate_exceptional_info_type_t + * @param[in] device_info: the device information. + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_gap_add_duplicate_scan_exceptional_device(esp_ble_duplicate_exceptional_info_type_t type, esp_duplicate_info_t device_info); + +/** + * @brief This function is called to remove a device info from the duplicate scan exceptional list. + * + * + * @param[in] type: device info type, it is defined in esp_ble_duplicate_exceptional_info_type_t + * @param[in] device_info: the device information. + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_gap_remove_duplicate_scan_exceptional_device(esp_ble_duplicate_exceptional_info_type_t type, esp_duplicate_info_t device_info); + +/** + * @brief This function is called to clean the duplicate scan exceptional list. + * This API will delete all device information in the duplicate scan exceptional list. + * + * + * @param[in] list_type: duplicate scan exceptional list type, the value can be one or more of esp_duplicate_scan_exceptional_list_type_t. + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_gap_clean_duplicate_scan_exceptional_list(esp_duplicate_scan_exceptional_list_type_t list_type); + #if (SMP_INCLUDED == TRUE) /** * @brief Set a GAP security parameter value. Overrides the default value. diff --git a/components/bt/bluedroid/bta/dm/bta_dm_act.c b/components/bt/bluedroid/bta/dm/bta_dm_act.c index 77aed3824..296e433c5 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_act.c @@ -4879,6 +4879,22 @@ void bta_dm_ble_set_adv_params_all (tBTA_DM_MSG *p_data) } } +/******************************************************************************* +** +** Function bta_dm_ble_update_duplicate_exceptional_list +** +** Description This function is to update duplicate scan exceptional list +** +** +*******************************************************************************/ +void bta_dm_ble_update_duplicate_exceptional_list(tBTA_DM_MSG *p_data) +{ + BTM_UpdateBleDuplicateExceptionalList(p_data->ble_duplicate_exceptional_list.subcode, + p_data->ble_duplicate_exceptional_list.type, + p_data->ble_duplicate_exceptional_list.device_info, + p_data->ble_duplicate_exceptional_list.exceptional_list_cb); +} + /******************************************************************************* ** ** Function bta_dm_ble_set_adv_config diff --git a/components/bt/bluedroid/bta/dm/bta_dm_api.c b/components/bt/bluedroid/bta/dm/bta_dm_api.c index 673a7dceb..fd06e4e7a 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_api.c @@ -1258,6 +1258,34 @@ void BTA_DmBleSetScanRspRaw (UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len, } } +/******************************************************************************* +** +** Function BTA_DmUpdateDuplicateExceptionalList +** +** Description This function is called to update duplicate scan exceptional list +** +** Parameters subcode : add, remove or clean duplicate scan exceptional list. +** type : device info type. +** device_info: device info +** p_update_duplicate_ignore_list_cback : update complete callback. +** +** Returns None +** +*******************************************************************************/ +void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type, BD_ADDR device_info, tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK p_update_duplicate_exceptional_list_cback) +{ + tBTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST *p_msg; + if ((p_msg = (tBTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST *)osi_malloc(sizeof(tBTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST))) != NULL) { + p_msg->hdr.event = BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT; + p_msg->subcode = subcode; + p_msg->type = type; + p_msg->exceptional_list_cb = p_update_duplicate_exceptional_list_cback; + memcpy(p_msg->device_info, device_info, sizeof(BD_ADDR)); + + bta_sys_sendmsg(p_msg); + } +} + /******************************************************************************* ** ** Function BTA_DmBleSetStorageParams diff --git a/components/bt/bluedroid/bta/dm/bta_dm_main.c b/components/bt/bluedroid/bta/dm/bta_dm_main.c index aa651c267..ae8f8a477 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_main.c @@ -157,6 +157,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { bta_dm_update_white_list, /* BTA_DM_API_UPDATE_WHITE_LIST_EVT */ bta_dm_ble_read_adv_tx_power, /* BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT */ bta_dm_ble_read_rssi, /* BTA_DM_API_BLE_READ_RSSI_EVT */ + bta_dm_ble_update_duplicate_exceptional_list,/* BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT */ }; diff --git a/components/bt/bluedroid/bta/dm/include/bta_dm_int.h b/components/bt/bluedroid/bta/dm/include/bta_dm_int.h index ea1c6e8a6..eb4734bf3 100644 --- a/components/bt/bluedroid/bta/dm/include/bta_dm_int.h +++ b/components/bt/bluedroid/bta/dm/include/bta_dm_int.h @@ -155,6 +155,7 @@ enum { BTA_DM_API_UPDATE_WHITE_LIST_EVT, BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT, BTA_DM_API_BLE_READ_RSSI_EVT, + BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT, BTA_DM_MAX_EVT }; @@ -193,6 +194,14 @@ typedef struct { tBTA_ADD_WHITELIST_CBACK *add_wl_cb; }tBTA_DM_API_UPDATE_WHITE_LIST; +typedef struct { + BT_HDR hdr; + UINT8 subcode; + UINT32 type; + BD_ADDR device_info; + tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK *exceptional_list_cb; +}tBTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST; + typedef struct { BT_HDR hdr; tBTA_CMPL_CB *read_tx_power_cb; @@ -848,6 +857,7 @@ typedef union { tBTA_DM_API_TRACK_ADVERTISER ble_track_advert; tBTA_DM_API_ENERGY_INFO ble_energy_info; tBTA_DM_API_BLE_DISCONNECT ble_disconnect; + tBTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST ble_duplicate_exceptional_list; #endif tBTA_DM_API_REMOVE_ACL remove_acl; @@ -1243,7 +1253,7 @@ extern void bta_dm_ble_set_scan_rsp (tBTA_DM_MSG *p_data); extern void bta_dm_ble_set_scan_rsp_raw (tBTA_DM_MSG *p_data); extern void bta_dm_ble_broadcast (tBTA_DM_MSG *p_data); extern void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data); - +extern void bta_dm_ble_update_duplicate_exceptional_list(tBTA_DM_MSG *p_data); #if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE extern void bta_dm_cfg_filter_cond (tBTA_DM_MSG *p_data); extern void bta_dm_scan_filter_param_setup (tBTA_DM_MSG *p_data); diff --git a/components/bt/bluedroid/bta/include/bta/bta_api.h b/components/bt/bluedroid/bta/include/bta/bta_api.h index 74c987c1a..b9e82fd0f 100644 --- a/components/bt/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/bluedroid/bta/include/bta/bta_api.h @@ -399,6 +399,8 @@ typedef struct { UINT8 tx_power; } tBTA_BLE_ADV_DATA; +typedef void (tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTA_STATUS status, uint8_t subcode, uint32_t length, uint8_t *device_info); + typedef void (tBTA_SET_ADV_DATA_CMPL_CBACK) (tBTA_STATUS status); typedef tBTM_START_ADV_CMPL_CBACK tBTA_START_ADV_CMPL_CBACK; @@ -2244,6 +2246,24 @@ extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask, extern void BTA_DmBleSetScanRspRaw (UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len, tBTA_SET_ADV_DATA_CMPL_CBACK *p_scan_rsp_data_cback); +/******************************************************************************* +** +** Function BTA_DmUpdateDuplicateExceptionalList +** +** Description This function is called to update duplicate scan exceptional list +** +** Parameters subcode : add, remove or clean duplicate scan exceptional list. +** type : device info type. +** device_info: device info +** p_update_duplicate_ignore_list_cback : update complete callback. +** +** Returns None +** +*******************************************************************************/ +extern void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type, + BD_ADDR device_info, + tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK p_update_duplicate_exceptional_list_cback); + /******************************************************************************* ** ** Function BTA_DmBleBroadcast diff --git a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c index 36432c164..2955110df 100644 --- a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -426,6 +426,35 @@ static void btc_stop_adv_callback(uint8_t status) } } +void btc_update_duplicate_exceptional_list_callback(tBTA_STATUS status, uint8_t subcode, uint32_t length, uint8_t *device_info) +{ + esp_ble_gap_cb_param_t param; + bt_status_t ret; + btc_msg_t msg; + + msg.sig = BTC_SIG_API_CB; + msg.pid = BTC_PID_GAP_BLE; + msg.act = ESP_GAP_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_COMPLETE_EVT; + param.update_duplicate_exceptional_list_cmpl.status = status; + param.update_duplicate_exceptional_list_cmpl.subcode = subcode; + if(length > sizeof(param.update_duplicate_exceptional_list_cmpl.device_info)) { + length = sizeof(param.update_duplicate_exceptional_list_cmpl.device_info); + } + param.update_duplicate_exceptional_list_cmpl.length = length; + memcpy(param.update_duplicate_exceptional_list_cmpl.device_info, device_info, length); + ret = btc_transfer_context(&msg, ¶m, sizeof(esp_ble_gap_cb_param_t), NULL); + + if (ret != BT_STATUS_SUCCESS) { + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); + } +} + +static void btc_ble_update_duplicate_exceptional_list(uint8_t subcode, uint32_t info_type, BD_ADDR device_info, + tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK p_update_duplicate_ignore_list_cback) +{ + BTA_DmUpdateDuplicateExceptionalList(subcode, info_type, device_info, p_update_duplicate_ignore_list_cback); +} + static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params, tBTA_START_ADV_CMPL_CBACK start_adv_cback) { tBLE_BD_ADDR peer_addr; @@ -1089,6 +1118,12 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) arg->cfg_scan_rsp_data_raw.raw_scan_rsp_len, btc_scan_rsp_data_raw_callback); break; + case BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST: + btc_ble_update_duplicate_exceptional_list(arg->update_duplicate_exceptional_list.subcode, + arg->update_duplicate_exceptional_list.info_type, + arg->update_duplicate_exceptional_list.device_info, + btc_update_duplicate_exceptional_list_callback); + break; #if (SMP_INCLUDED == TRUE) case BTC_GAP_BLE_SET_ENCRYPTION_EVT: { BD_ADDR bd_addr; diff --git a/components/bt/bluedroid/btc/profile/std/include/btc_gap_ble.h b/components/bt/bluedroid/btc/profile/std/include/btc_gap_ble.h index b73759481..81952abff 100644 --- a/components/bt/bluedroid/btc/profile/std/include/btc_gap_ble.h +++ b/components/bt/bluedroid/btc/profile/std/include/btc_gap_ble.h @@ -46,6 +46,7 @@ typedef enum { BTC_GAP_BLE_CONFIRM_REPLY_EVT, BTC_GAP_BLE_DISCONNECT_EVT, BTC_GAP_BLE_REMOVE_BOND_DEV_EVT, + BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST, } btc_gap_ble_act_t; /* btc_ble_gap_args_t */ @@ -94,6 +95,12 @@ typedef union { bool add_remove; esp_bd_addr_t remote_bda; }update_white_list; + //BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST + struct update_duplicate_exceptional_list_args { + uint8_t subcode; + uint32_t info_type; + esp_duplicate_info_t device_info; + }update_duplicate_exceptional_list; //BTC_GAP_BLE_ACT_SET_CONN_PARAMS struct set_conn_params_args { esp_bd_addr_t bd_addr; diff --git a/components/bt/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/bluedroid/stack/btm/btm_ble_gap.c index 64a078a48..4e8adc3f7 100644 --- a/components/bt/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/bluedroid/stack/btm/btm_ble_gap.c @@ -1647,6 +1647,52 @@ tBTM_STATUS BTM_BleWriteScanRspRaw(UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_le } } +/******************************************************************************* +** +** Function BTM_UpdateBleDuplicateExceptionalList +** +** Description This function is called to update duplicate scan exceptional list. +** +** Parameters: subcode: add, remove or clean duplicate scan exceptional list. +** type: device info type +** device_info: device information +** update_exceptional_list_cmp_cb: complete callback +** +** Returns status +** +*******************************************************************************/ +tBTM_STATUS BTM_UpdateBleDuplicateExceptionalList(uint8_t subcode, uint32_t type, BD_ADDR device_info, + tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK update_exceptional_list_cmp_cb) +{ + tBTM_BLE_CB *ble_cb = &btm_cb.ble_ctr_cb; + ble_cb->update_exceptional_list_cmp_cb = update_exceptional_list_cmp_cb; + tBTM_STATUS status = BTM_NO_RESOURCES; + if (!controller_get_interface()->supports_ble()) { + return BTM_ILLEGAL_VALUE; + } + if(!device_info) { + return BTM_ILLEGAL_VALUE; + } + // subcoe + type + device info + uint8_t device_info_array[1 + 4 + BD_ADDR_LEN] = {0}; + device_info_array[0] = subcode; + device_info_array[1] = type & 0xff; + device_info_array[2] = (type >> 8) & 0xff; + device_info_array[3] = (type >> 16) & 0xff; + device_info_array[4] = (type >> 24) & 0xff; + if(type == BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_ADV_ADDR) { + bt_rcopy(&device_info_array[5], device_info, BD_ADDR_LEN); + } else { + memcpy(&device_info_array[5], device_info, 4); + } + status = BTM_VendorSpecificCommand(HCI_VENDOR_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST, 1 + 4 + BD_ADDR_LEN, device_info_array, NULL); + if(status == BTM_CMD_STARTED) { + status = BTM_SUCCESS; + } + + return status; +} + /******************************************************************************* ** ** Function BTM_BleWriteAdvData diff --git a/components/bt/bluedroid/stack/btm/btm_devctl.c b/components/bt/bluedroid/stack/btm/btm_devctl.c index 41bfb92f0..6fd1edddc 100644 --- a/components/bt/bluedroid/stack/btm/btm_devctl.c +++ b/components/bt/bluedroid/stack/btm/btm_devctl.c @@ -689,6 +689,21 @@ tBTM_STATUS BTM_VendorSpecificCommand(UINT16 opcode, UINT8 param_len, void btm_vsc_complete (UINT8 *p, UINT16 opcode, UINT16 evt_len, tBTM_CMPL_CB *p_vsc_cplt_cback) { + tBTM_BLE_CB *ble_cb = &btm_cb.ble_ctr_cb; + switch(opcode) { + case HCI_VENDOR_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST: { + uint8_t subcode, status; uint32_t length; + STREAM_TO_UINT8(status, p); + STREAM_TO_UINT8(subcode, p); + STREAM_TO_UINT32(length, p); + if(ble_cb && ble_cb->update_exceptional_list_cmp_cb) { + (*ble_cb->update_exceptional_list_cmp_cb)(status, subcode, length, p); + } + break; + } + default: + break; + } tBTM_VSC_CMPL vcs_cplt_params; /* If there was a callback address for vcs complete, call it */ diff --git a/components/bt/bluedroid/stack/btm/include/btm_ble_int.h b/components/bt/bluedroid/stack/btm/include/btm_ble_int.h index 9679afffa..2a29a333b 100644 --- a/components/bt/bluedroid/stack/btm/include/btm_ble_int.h +++ b/components/bt/bluedroid/stack/btm/include/btm_ble_int.h @@ -280,6 +280,9 @@ typedef UINT16 tBTM_BLE_STATE_MASK; #define BTM_LE_RESOLVING_LIST_MAX 0x20 #endif +#define BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_ADV_ADDR 0 +#define BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_LINK_ID 1 + typedef struct { BD_ADDR *resolve_q_random_pseudo; UINT8 *resolve_q_action; @@ -358,6 +361,7 @@ typedef struct { /* current BLE link state */ tBTM_BLE_STATE_MASK cur_states; /* bit mask of tBTM_BLE_STATE */ UINT8 link_count[2]; /* total link count master and slave*/ + tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK *update_exceptional_list_cmp_cb; } tBTM_BLE_CB; #ifdef __cplusplus diff --git a/components/bt/bluedroid/stack/include/stack/bt_types.h b/components/bt/bluedroid/stack/include/stack/bt_types.h index ec44cb871..52385cb51 100644 --- a/components/bt/bluedroid/stack/include/stack/bt_types.h +++ b/components/bt/bluedroid/stack/include/stack/bt_types.h @@ -790,4 +790,22 @@ static inline void bdsetany(BD_ADDR a) { bdcpy(a, bd_addr_any); } + +/******************************************************************************* +** +** Function bt_rcopy +** +** Description memory reverse and copy. +** +** +** Returns void +** +*******************************************************************************/ +static inline void bt_rcopy(UINT8 *dst, UINT8 const *src, UINT16 len) +{ + src += len; + while (len --) { + *dst++ = *--src; + } +} #endif diff --git a/components/bt/bluedroid/stack/include/stack/btm_ble_api.h b/components/bt/bluedroid/stack/include/stack/btm_ble_api.h index a019dd4fe..355bafb7b 100644 --- a/components/bt/bluedroid/stack/include/stack/btm_ble_api.h +++ b/components/bt/bluedroid/stack/include/stack/btm_ble_api.h @@ -867,6 +867,7 @@ tBTM_BLE_SCAN_SETUP_CBACK bta_ble_scan_setup_cb; typedef void (tBTM_START_ADV_CMPL_CBACK) (UINT8 status); typedef void (tBTM_START_STOP_ADV_CMPL_CBACK) (UINT8 status); +typedef void (tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTM_STATUS status, uint8_t subcode, uint32_t length, uint8_t *device_info); /***************************************************************************** @@ -2053,6 +2054,22 @@ tBTM_STATUS BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback); //extern tBTM_STATUS BTM_SetBleDataLength(BD_ADDR bd_addr, UINT16 tx_pdu_length); +/******************************************************************************* +** +** Function BTM_UpdateBleDuplicateExceptionalList +** +** Description This function is called to update duplicate scan exceptional list. +** +** Parameters: subcode: add, remove or clean duplicate scan exceptional list. +** type: device info type +** device_info: device information +** update_exceptional_list_cmp_cb: complete callback +** +** Returns status +** +*******************************************************************************/ + +tBTM_STATUS BTM_UpdateBleDuplicateExceptionalList(uint8_t subcode, uint32_t type, BD_ADDR device_info, tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK update_exceptional_list_cmp_cb); /* #ifdef __cplusplus } diff --git a/components/bt/lib b/components/bt/lib index aee5ed577..fbc860762 160000 --- a/components/bt/lib +++ b/components/bt/lib @@ -1 +1 @@ -Subproject commit aee5ed577e52fb45feaa6a10c4444176b890b84b +Subproject commit fbc8607624ddfd9353adb7886db3f8c02d8e704e