]> granicus.if.org Git - esp-idf/commitdiff
Component/bt: add check peer addr type in set adv params
authorzhiweijian <zhiweijian@espressif.com>
Mon, 19 Nov 2018 09:29:04 +0000 (17:29 +0800)
committerzhiweijian <zhiweijian@espressif.com>
Mon, 19 Nov 2018 11:46:41 +0000 (19:46 +0800)
components/bt/bluedroid/api/include/esp_gap_ble_api.h
components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c

index 5ce19870d5b52d3ed28bb2d502d6305447902176..6c8069a64946962bfdbe979e88b29681ea8195bb 100644 (file)
@@ -219,7 +219,7 @@ typedef struct {
     esp_ble_adv_type_t      adv_type;           /*!< Advertising type */
     esp_ble_addr_type_t     own_addr_type;      /*!< Owner bluetooth device address type */
     esp_bd_addr_t           peer_addr;          /*!< Peer device bluetooth device address */
-    esp_ble_addr_type_t     peer_addr_type;     /*!< Peer device bluetooth device address type */
+    esp_ble_addr_type_t     peer_addr_type;     /*!< Peer device bluetooth device address type, only support public address type and random address type */
     esp_ble_adv_channel_t   channel_map;        /*!< Advertising channel map */
     esp_ble_adv_filter_t    adv_filter_policy;  /*!< Advertising filter policy */
 } esp_ble_adv_params_t;
index 1f0c4a5806a332f33b9bbaf639278f150d5e3ee7..f30326dc9ba4d50d9c355ff6aab61ab1bd0b60c3 100644 (file)
@@ -514,6 +514,12 @@ static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params, tBT
         status = ESP_BT_STATUS_PARM_INVALID;
         LOG_ERROR("Invalid advertisting channel map parameters.\n");
     }
+
+    if (!BLE_ISVALID_PARAM(ble_adv_params->peer_addr_type, BLE_ADDR_TYPE_PUBLIC, BLE_ADDR_TYPE_RANDOM)) {
+        status = ESP_BT_STATUS_PARM_INVALID;
+        LOG_ERROR("Invalid advertisting peer address type parameters.\n");
+    }
+
     if(status != ESP_BT_STATUS_SUCCESS) {
         if(start_adv_cback) {
             start_adv_cback(status);