Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

sd_ble_gap_tx_power_set usage

Hello Nordic Support team,

we wanted to know the right usage of sd_ble_gap_tx_power_set() function.

Right now we are setting the power using above function after the advertising init is done.

In our code there are number of places wherein we stop->init->start the advertisements.

My questions are

1 Is it necessary to call the sd_ble_gap_tx_power_set() function after every advertisement inits?

2. After connection, inside the BLE_GAP_EVT_CONNECTED do we need to set the transmit power again?

If so, should the power level be less than or more than one used for advertisement?

We are using nRF5_SDK_17.1.0 SDK and S112 softdevice.

Thanks,

Justin

Parents
  • Hi Justin.

    As you can see from the documentation: sd_ble_gap_tx_power_set()

    1)

    No.

    If role is BLE_GAP_TX_POWER_ROLE_ADV, the advertising set identified with the advertising handle, will use the specified transmit power, and include it in the advertising packet headers if ble_gap_adv_properties_t::include_tx_power set.

    2)

    When a connection is created it will inherit the transmit power from the initiator or advertiser leading to the connection.

    If so, should the power level be less than or more than one used for advertisement?

    That is up to you to decide which transmit power you wish to use.

    Br,
    Joakim

  • If role is BLE_GAP_TX_POWER_ROLE_ADV, the advertising set identified with the advertising handle, will use the specified transmit power, and include it in the advertising packet headers if ble_gap_adv_properties_t::include_tx_power set.

    Thanks Joakim for your reply.

    We call sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params) function and set the advertisment parameters. 

    We call this function at many places but set the power by calling sd_ble_gap_tx_power_set() only at the beginning.

    Will ad_ble_gap_adv_set_configure() override the m_adv_handle and thus erasing the transmit power that was set earlier?

    For example if the code looks something like this.

       /*
    
        * set advertisement parameters and get advertisment handle
    
        */
    
        sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
    
        /*
    
        * set trasmit power to 4 using m_adv_handle
    
        */
    
        sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_adv_handle, 4);
    
        /*
    
        * reconfigure advertisement data and parameters
    
        */
    
        sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
        

        After this do we need to set the transmit power again? As the advertisement handle has changed

        will it reset previous settings?

    Thanks,

    Justin

Reply
  • If role is BLE_GAP_TX_POWER_ROLE_ADV, the advertising set identified with the advertising handle, will use the specified transmit power, and include it in the advertising packet headers if ble_gap_adv_properties_t::include_tx_power set.

    Thanks Joakim for your reply.

    We call sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params) function and set the advertisment parameters. 

    We call this function at many places but set the power by calling sd_ble_gap_tx_power_set() only at the beginning.

    Will ad_ble_gap_adv_set_configure() override the m_adv_handle and thus erasing the transmit power that was set earlier?

    For example if the code looks something like this.

       /*
    
        * set advertisement parameters and get advertisment handle
    
        */
    
        sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
    
        /*
    
        * set trasmit power to 4 using m_adv_handle
    
        */
    
        sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_adv_handle, 4);
    
        /*
    
        * reconfigure advertisement data and parameters
    
        */
    
        sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
        

        After this do we need to set the transmit power again? As the advertisement handle has changed

        will it reset previous settings?

    Thanks,

    Justin

Children
Related