From 3453824bf2bc04d7348a6a2653cf0276f2d22d8a Mon Sep 17 00:00:00 2001 From: Yulong Date: Fri, 5 May 2017 04:31:24 -0400 Subject: [PATCH 1/2] component/bt: component/bt: Check own address and filter policy for validity. --- .../bt/bluedroid/api/include/esp_bt_defs.h | 16 -------------- .../bluedroid/api/include/esp_gap_ble_api.h | 22 +++---------------- .../btc/profile/std/gap/btc_gap_ble.c | 6 +++-- components/bt/bluedroid/osi/include/thread.h | 2 +- 4 files changed, 8 insertions(+), 38 deletions(-) diff --git a/components/bt/bluedroid/api/include/esp_bt_defs.h b/components/bt/bluedroid/api/include/esp_bt_defs.h index c1f5ae59f8..85b0aff996 100644 --- a/components/bt/bluedroid/api/include/esp_bt_defs.h +++ b/components/bt/bluedroid/api/include/esp_bt_defs.h @@ -77,22 +77,6 @@ typedef enum { /// Bluetooth device address typedef uint8_t esp_bd_addr_t[ESP_BD_ADDR_LEN]; -/// Own BD address source of the device -typedef enum { - /// Public Address - BD_ADDR_PUBLIC, - /// Provided random address - BD_ADDR_PROVIDED_RND, - /// Provided static random address - BD_ADDR_GEN_STATIC_RND, - /// Generated resolvable private random address - BD_ADDR_GEN_RSLV, - /// Generated non-resolvable private random address - BD_ADDR_GEN_NON_RSLV, - /// Provided Reconnection address - BD_ADDR_PROVIDED_RECON, -} esp_bd_addr_type_t; - /// BLE device address type typedef enum { BLE_ADDR_TYPE_PUBLIC = 0x00, diff --git a/components/bt/bluedroid/api/include/esp_gap_ble_api.h b/components/bt/bluedroid/api/include/esp_gap_ble_api.h index a9bd0e48a1..45c14b5096 100644 --- a/components/bt/bluedroid/api/include/esp_gap_ble_api.h +++ b/components/bt/bluedroid/api/include/esp_gap_ble_api.h @@ -204,22 +204,6 @@ typedef struct { uint8_t flag; /*!< Advertising flag of discovery mode, see BLE_ADV_DATA_FLAG detail */ } esp_ble_adv_data_t; -/// Own BD address source of the device -typedef enum { - /// Public Address - ESP_PUBLIC_ADDR, - /// Provided random address - ESP_PROVIDED_RND_ADDR, - /// Provided static random address - ESP_GEN_STATIC_RND_ADDR, - /// Generated resolvable private random address - ESP_GEN_RSLV_ADDR, - /// Generated non-resolvable private random address - ESP_GEN_NON_RSLV_ADDR, - /// Provided Reconnection address - ESP_PROVIDED_RECON_ADDR, -} esp_ble_own_addr_src_t; - /// Ble scan type typedef enum { BLE_SCAN_TYPE_PASSIVE = 0x0, /*!< Passive scan */ @@ -299,7 +283,7 @@ typedef struct typedef struct { esp_bt_octet16_t irk; /*!< The irk value */ - esp_bd_addr_type_t addr_type; /*!< The address type */ + esp_ble_addr_type_t addr_type; /*!< The address type */ esp_bd_addr_t static_addr; /*!< The static address */ }esp_ble_pid_keys_t; /*!< The pid key type */ @@ -351,7 +335,7 @@ typedef union esp_ble_pcsrk_keys_t pcsrk_key; /*!< received peer device SRK */ esp_ble_pid_keys_t pid_key; /*!< peer device ID key */ esp_ble_lenc_keys_t lenc_key; /*!< local encryption reproduction keys LTK = = d1(ER,DIV,0)*/ - esp_ble_lcsrk_keys lcsrk_key; /*!< local device CSRK = d1(ER,DIV,1)*/ + esp_ble_lcsrk_keys lcsrk_key; /*!< local device CSRK = d1(ER,DIV,1)*/ }esp_ble_key_value_t; /*!< ble key value type*/ @@ -386,7 +370,7 @@ typedef struct uint8_t key_type; /*!< The type of Link Key */ bool success; /*!< TRUE of authentication succeeded, FALSE if failed. */ uint8_t fail_reason; /*!< The HCI reason/error code for when success=FALSE */ - esp_bd_addr_type_t addr_type; /*!< Peer device address type */ + esp_ble_addr_type_t addr_type; /*!< Peer device address type */ esp_bt_dev_type_t dev_type; /*!< Device type */ }esp_ble_auth_cmpl_t; /*!< The ble authentication complite cb type */ 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 1d2f7f820c..c07b16be9d 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 @@ -465,8 +465,10 @@ static void btc_scan_params_callback(tGATT_IF gatt_if, tBTM_STATUS status) static void btc_ble_set_scan_params(esp_ble_scan_params_t *scan_params, tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback) { if (BLE_ISVALID_PARAM(scan_params->scan_interval, BTM_BLE_SCAN_INT_MIN, BTM_BLE_SCAN_INT_MAX) && - BLE_ISVALID_PARAM(scan_params->scan_window, BTM_BLE_SCAN_WIN_MIN, BTM_BLE_SCAN_WIN_MAX) && - (scan_params->scan_type == BTM_BLE_SCAN_MODE_ACTI || scan_params->scan_type == BTM_BLE_SCAN_MODE_PASS)) { + BLE_ISVALID_PARAM(scan_params->scan_window, BTM_BLE_SCAN_WIN_MIN, BTM_BLE_SCAN_WIN_MAX) && + BLE_ISVALID_PARAM(scan_params->own_addr_type, BLE_ADDR_TYPE_PUBLIC, BLE_ADDR_TYPE_RPA_RANDOM) && + BLE_ISVALID_PARAM(scan_params->scan_filter_policy, BLE_SCAN_FILTER_ALLOW_ALL, BLE_SCAN_FILTER_ALLOW_WLIST_PRA_DIR) && + (scan_params->scan_type == BTM_BLE_SCAN_MODE_ACTI || scan_params->scan_type == BTM_BLE_SCAN_MODE_PASS)) { BTA_DmSetBleScanFilterParams(ESP_DEFAULT_GATT_IF, /*client_if*/ scan_params->scan_interval, scan_params->scan_window, diff --git a/components/bt/bluedroid/osi/include/thread.h b/components/bt/bluedroid/osi/include/thread.h index f1e743fe4e..c10f8c2afd 100644 --- a/components/bt/bluedroid/osi/include/thread.h +++ b/components/bt/bluedroid/osi/include/thread.h @@ -52,7 +52,7 @@ enum { #define HCI_H4_TASK_NAME "hciH4T" #define HCI_H4_QUEUE_NUM 60 -#define BTU_TASK_STACK_SIZE (3584 + BT_TASK_EXTRA_STACK_SIZE) +#define BTU_TASK_STACK_SIZE (4096 + BT_TASK_EXTRA_STACK_SIZE) #define BTU_TASK_PRIO (configMAX_PRIORITIES - 5) #define BTU_TASK_NAME "btuT" #define BTU_QUEUE_NUM 50 From 0a56b748dfb2603dfd0ec75bbbd609f17000f1b5 Mon Sep 17 00:00:00 2001 From: Yulong Date: Fri, 5 May 2017 04:46:08 -0400 Subject: [PATCH 2/2] component/bt:change the ESP_PUBLIC_ADDR to BLE_ADDR_TYPE_PUBLIC. --- examples/bluetooth/gatt_client/main/gattc_demo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/bluetooth/gatt_client/main/gattc_demo.c b/examples/bluetooth/gatt_client/main/gattc_demo.c index 48b1062a6d..17ca741028 100644 --- a/examples/bluetooth/gatt_client/main/gattc_demo.c +++ b/examples/bluetooth/gatt_client/main/gattc_demo.c @@ -72,7 +72,7 @@ static const char device_name[] = "Alert Notification"; static esp_ble_scan_params_t ble_scan_params = { .scan_type = BLE_SCAN_TYPE_ACTIVE, - .own_addr_type = ESP_PUBLIC_ADDR, + .own_addr_type = BLE_ADDR_TYPE_PUBLIC, .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL, .scan_interval = 0x50, .scan_window = 0x30