]> granicus.if.org Git - esp-idf/commitdiff
fix TX power value in ble adv data is incorrect
authorTian Hao <tianhao@espressif.com>
Tue, 4 Sep 2018 11:31:34 +0000 (19:31 +0800)
committerbot <bot@espressif.com>
Wed, 12 Sep 2018 10:19:08 +0000 (10:19 +0000)
refence to https://github.com/espressif/esp-idf/issues/2284
Before fixing, the tx power in adv data is always 0xeb(-21dbm).

restriction:
    If change BLE advertising TX power, please call esp_ble_gap_config_adv_data()
    after BLE adv TX power changed.

    Later, will implement set BLE advertising TX power via HCI, then the
    TX power value in adv data can be update automatically after BLE adv
    TX power changed.

components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c
components/bt/bluedroid/common/include/common/bt_target.h
components/bt/bluedroid/stack/btm/btm_ble_multi_adv.c
components/bt/bluedroid/stack/include/stack/btm_ble_api.h

index c8951db4c446c7f965afd04b7bc1d703ba2bb466..7200be90f54b1fcb799ac830cd7a7501a7b56c46 100644 (file)
@@ -29,6 +29,7 @@
 #include "btc/btc_dm.h"
 #include "btc/btc_util.h"
 #include "osi/mutex.h"
+#include "esp_bt.h"
 
 static tBTA_BLE_ADV_DATA gl_bta_adv_data;
 static tBTA_BLE_ADV_DATA gl_bta_scan_rsp_data;
@@ -142,6 +143,7 @@ static void btc_to_bta_adv_data(esp_ble_adv_data_t *p_adv_data, tBTA_BLE_ADV_DAT
 
     if (p_adv_data->include_txpower) {
         mask |= BTM_BLE_AD_BIT_TX_PWR;
+        bta_adv_data->tx_power = esp_ble_tx_power_get(ESP_BLE_PWR_TYPE_ADV);
     }
 
     if (p_adv_data->min_interval > 0 && p_adv_data->max_interval > 0 &&
index 87d2a7a0d2addc8ca09681ebf4a0cf7419e5e45c..67abfd420553cba9a036e826dbecff6981abfada 100644 (file)
 #endif
 
 #ifndef BTM_BLE_ADV_TX_POWER
-#define BTM_BLE_ADV_TX_POWER {-21, -15, -7, 1, 9}
+#define BTM_BLE_ADV_TX_POWER {-12, -9, -6, -3, 0, 3, 6, 9}
 #endif
 
 
index dba7d56b2eeedc1c1f2fa70259680e80637babae..54573241305bed12294c7a50088665a9b64159ba 100644 (file)
@@ -222,10 +222,10 @@ tBTM_STATUS btm_ble_enable_multi_adv (BOOLEAN enable, UINT8 inst_id, UINT8 cb_ev
 ** Returns          tx power in dBm
 **
 *******************************************************************************/
-int btm_ble_tx_power[BTM_BLE_ADV_TX_POWER_MAX + 1] = BTM_BLE_ADV_TX_POWER;
+static const int btm_ble_tx_power[BTM_BLE_ADV_TX_POWER_MAX + 1] = BTM_BLE_ADV_TX_POWER;
 char btm_ble_map_adv_tx_power(int tx_power_index)
 {
-    if (0 <= tx_power_index && tx_power_index < BTM_BLE_ADV_TX_POWER_MAX) {
+    if (0 <= tx_power_index && tx_power_index <= BTM_BLE_ADV_TX_POWER_MAX) {
         return (char)btm_ble_tx_power[tx_power_index];
     }
     return 0;
index 0c96eaa5e8a889bf7cc1d0ea543678032970563c..b470bd0d0078cca77b9cd7f0c1d33528f98d72ae 100644 (file)
@@ -375,10 +375,7 @@ typedef UINT8   tBTM_BLE_AD_TYPE;
 
 /* adv tx power level */
 #define BTM_BLE_ADV_TX_POWER_MIN        0           /* minimum tx power */
-#define BTM_BLE_ADV_TX_POWER_LOW        1           /* low tx power     */
-#define BTM_BLE_ADV_TX_POWER_MID        2           /* middle tx power  */
-#define BTM_BLE_ADV_TX_POWER_UPPER      3           /* upper tx power   */
-#define BTM_BLE_ADV_TX_POWER_MAX        4           /* maximum tx power */
+#define BTM_BLE_ADV_TX_POWER_MAX        7           /* maximum tx power */
 typedef UINT8 tBTM_BLE_ADV_TX_POWER;
 
 /* adv tx power in dBm */