Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Just Set Tx Power?

I just want to globally set the power level, and forget about it.

I have seen this post, and it still seems unclear how to do this - or if it's even possible.

Is there a way that I can simply set this once at startup, and then it will never change - whether advertising, or connected, or whatever?

If so, how?

Peripheral and Central.

Not Mesh.

nRF52 SDK 15.0.0 SoftDevices S112 (Peripheral) and S132 (Central).

Parents
  • Hi,

    The sd_ble_gap_tx_power_set() function was updated in version 6.0.0 of the SoftDevices, and now allows you to set the TX power per connection. This does not mean that you have to set it per connection, though.

    As a peripheral, any connection inherits the TX power that was set for the advertising role (BLE_GAP_TX_POWER_ROLE_ADV), so you only need to set it once before the first connection is made to get the same behavior as before. For the central it is the same, you only need to set it once with the scanner/initiator role (BLE_GAP_TX_POWER_ROLE_SCAN_INIT), and then this is used for the connection as well unless you make a new call to sd_ble_gap_tx_power_set() with the BLE_GAP_TX_POWER_ROLE_CONN and a connection handle.

  • The handle parameter depends on the value of the role parameter:

    • For the  BLE_GAP_TX_POWER_ROLE_CONN role, the handle is the connection handle that you for instance get from the BLE_GAP_EVT_CONNECTED event. (Most SDK examples put this is a global variable called m_conn_handle).
    • For the BLE_GAP_TX_POWER_ROLE_ADV role, the handle is the advertising set handle. Assuming you use the SDK advertising module you can get this from the ble_advertising_tinstance you passed to ble_advertising_init() after it returns. It would be ble_advertising_t::adv_handle (m_advertising.adv_handle in most SDK examples). I have to admit that this is a bit weird, as the SoftDevice only support a single advertising set...
    • For the BLE_GAP_TX_POWER_ROLE_SCAN_INIT role the handle is ignored, so you can set anything.
Reply
  • The handle parameter depends on the value of the role parameter:

    • For the  BLE_GAP_TX_POWER_ROLE_CONN role, the handle is the connection handle that you for instance get from the BLE_GAP_EVT_CONNECTED event. (Most SDK examples put this is a global variable called m_conn_handle).
    • For the BLE_GAP_TX_POWER_ROLE_ADV role, the handle is the advertising set handle. Assuming you use the SDK advertising module you can get this from the ble_advertising_tinstance you passed to ble_advertising_init() after it returns. It would be ble_advertising_t::adv_handle (m_advertising.adv_handle in most SDK examples). I have to admit that this is a bit weird, as the SoftDevice only support a single advertising set...
    • For the BLE_GAP_TX_POWER_ROLE_SCAN_INIT role the handle is ignored, so you can set anything.
Children
Related