how to set BLE transmit power above 3dB?

ea2020
Posts: 1
Joined: Thu Mar 12, 2020 8:03 pm

how to set BLE transmit power above 3dB?

Postby ea2020 » Thu Mar 12, 2020 8:48 pm

I have my basic solution working (Adafruit ESP32 Feather to custom iOS application), but am not quite getting the range I want.

esp_bt.h enums the available esp_ble_power_type_t and esp_power_level_t to use when calling:

Code: Select all

esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level)
These suggest that using ESP_PWR_LVL_P9 should result in a +9 dB transmit power rather than the +3 dB default.

BLEDevice.cpp shows that the BLEDevice::setPower method calls the above function and sets the default power (ESP_BLE_PWR_TYPE_DEFAULT) to whatever power level is passed in with the call.

I've tried calling BLEDevice::setPower in many places (immediately after my call to BLEDevice::init, in my server callbacks after a successful connection, etc.). But, I always end up with +3dB of transmit power according the the nRF connect app (range and RSSI values also remain unchanged).

Digging through the IDF documentation, I found the following function:

Code: Select all

 esp_bredr_tx_power_set(esp_power_level_tmin_power_level, esp_power_level_tmax_power_level)
There is a note saying that it must be called after esp_bt_controller_enable and before anything that would cause the RF section to transmit.

Since esp_bt_controller_enable is called in BLEDevice::init, I tried the following:

Code: Select all

BLEDevice::init()
esp_bredr_tx_power_set(ESP_PWR_LVL_N12, ESP_PWR_LVL_P9)
BLEDevice::setPower(ESP_PWR_LVL_P9).
I still only see +3 dB transmit power.

I cannot find a call to esp_bredr_tx_power_set anywhere within the arduino IDE BLE source files (1.0.4/libraries/BLE/src), so I do not know where the default esp_power_level_tmax_power_level is being set.

Does anyone have any suggestions of what I am doing wrong?

If not, can anyone tell me where the +3 dB default value is set so I could at least hack something ugly together to test with +9 dB?

GYC-Espressif
Posts: 5
Joined: Tue Dec 31, 2019 9:57 am

Re: how to set BLE transmit power above 3dB?

Postby GYC-Espressif » Fri Mar 13, 2020 1:08 pm

Hello. This function is provided by ESP-IDF. And you can use it in following ways.
  1. /**
  2.  * @brief  Set BLE TX power
  3.  *         Connection Tx power should only be set after connection created.
  4.  * @param  power_type : The type of which tx power, could set Advertising/Connection/Default and etc
  5.  * @param  power_level: Power level(index) corresponding to absolute value(dbm)
  6.  * @return              ESP_OK - success, other - failed
  7.  */
  8. esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level);
To set the 9dB tx Power for adv, you can set it as
  1. esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_ADV,ESP_PWR_LVL_P9);
Thanks.

Who is online

Users browsing this forum: MicroController and 126 guests