From b59708ca87d6d5f711017a41223a43108d3e3958 Mon Sep 17 00:00:00 2001 From: baohongde Date: Wed, 20 Sep 2017 19:53:50 +0800 Subject: [PATCH] component/bt: Fix bug of function btc_ble_set_rand_addr --- components/bt/bluedroid/api/include/esp_gap_ble_api.h | 4 ++-- components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) 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 62d5c9b09..9292f95e6 100644 --- a/components/bt/bluedroid/api/include/esp_gap_ble_api.h +++ b/components/bt/bluedroid/api/include/esp_gap_ble_api.h @@ -864,9 +864,9 @@ esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr); /** * @brief Set a GAP security parameter value. Overrides the default value. * -* @param[in] param_type :L the type of the param which to be set +* @param[in] param_type : the type of the param which to be set * @param[in] value : the param value -* @param[out] len : the length of the param value +* @param[in] len : the length of the param value * * @return - ESP_OK : success * - other : failed 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 6a7bb0bef..d77b1249f 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 @@ -805,14 +805,14 @@ static void btc_ble_set_rand_addr (BD_ADDR rand_addr) BD_ADDR invalid_rand_addr_a, invalid_rand_addr_b; memset(invalid_rand_addr_a, 0xff, sizeof(BD_ADDR)); memset(invalid_rand_addr_b, 0x00, sizeof(BD_ADDR)); - invalid_rand_addr_b[BD_ADDR_LEN - 1] = invalid_rand_addr_b[BD_ADDR_LEN - 1] | BT_STATIC_RAND_ADDR_MASK; - if((rand_addr[BD_ADDR_LEN - 1] & BT_STATIC_RAND_ADDR_MASK) == BT_STATIC_RAND_ADDR_MASK + invalid_rand_addr_b[0] = invalid_rand_addr_b[0] | BT_STATIC_RAND_ADDR_MASK; + if((rand_addr[0] & BT_STATIC_RAND_ADDR_MASK) == BT_STATIC_RAND_ADDR_MASK && memcmp(invalid_rand_addr_a, rand_addr, BD_ADDR_LEN) != 0 && memcmp(invalid_rand_addr_b, rand_addr, BD_ADDR_LEN) != 0){ BTA_DmSetRandAddress(rand_addr); } else { param.set_rand_addr_cmpl.status = ESP_BT_STATUS_INVALID_STATIC_RAND_ADDR; - LOG_ERROR("Invalid random address, the high bit should be 0b11, the random part shall not be to 1 or 0"); + LOG_ERROR("Invalid random address, the high bit should be 0b11, all bits of the random part shall not be to 1 or 0"); } } else { param.set_rand_addr_cmpl.status = ESP_BT_STATUS_INVALID_STATIC_RAND_ADDR;