This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Location to set Tx power in Advertisement and Connection mode. Also change them dynamically at runtime

Hello,

 

I am using nRF52840, SDK_16.0.0, S140 SoftDevice and Segger 4.16 for flashing the image. I am using ‘ble_app_blinky’.

 

I have few queries on setting Tx power level. I am using sd_ble_gap_tx_power_set() to change power level.

 

1) In example code what will be the default Tx power level.

 

2) To increase Tx power level during Advertisement I am adding below code within advertising_init(). Is this fine.

 

              err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &adv_params);

              APP_ERROR_CHECK(err_code);

   

              err_code = sd_ble_gap_tx_power_set( BLE_GAP_TX_POWER_ROLE_ADV, m_adv_handle, 8); // Set to +8 dBm

              APP_ERROR_CHECK(err_code);

 

3) Similarly, I want to increase Tx power during Connection established. For this, where can I call sd_ble_gap_tx_power_set(). Whether as part of conn_params_init() after ble_conn_params_init() or under BLE_GAP_EVT_CONNECTED case of ble_evt_handler().

              sd_ble_gap_tx_power_set( BLE_GAP_TX_POWER_ROLE_CONN, m_conn_handle, 8); // Set to 8 dBm

 

4) Once after disconnection we need Advertisement packets to be stared. Once again do we need to call sd_ble_gap_tx_power_set() as part of advertising_start() to set power level of Advertisement packet.

 

5) Need more inputs on below statement in ble_gap.h. Assume my Central / Initiator has 0 dBm and my Peripheral / Advertiser has 8 dBm. Once Connection request is received whether Peripheral Tx power will be changed from 8 dBm to 0 dBm.

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

6) In Advertisement or Connection mode whether can I change Tx power level dynamically. Use case is, when my battery is getting depleted I want to reduce Tx power level so that I can maintain better battery life. advertising_init() is called only once. Whether can I call  sd_ble_gap_tx_power_set() as part of advertising_start().

 

Thanks & Regards

Vishnu Beema

Parents
  • Hi Vishnu

    1.

    a)  

    uint32_t err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN, m_conn_handle, -40); 
    	    APP_ERROR_CHECK(err_code); 
                break;
      See this case for an explanation.

    b) Yes, you can make the application check for I.E. battery power during a connection as well, but seeing as a connection will time out, it should be sufficient doing this during advertising start, for example.

    2. You're correct. I guess it's just that my suggestion is to set the TX power in the advertising_start and not during init, so that the application can check what TX power it should use at the start of each advertisement.

    3. Please see this case for information on the TX power service.

    Best regards,

    Simon

Reply
  • Hi Vishnu

    1.

    a)  

    uint32_t err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN, m_conn_handle, -40); 
    	    APP_ERROR_CHECK(err_code); 
                break;
      See this case for an explanation.

    b) Yes, you can make the application check for I.E. battery power during a connection as well, but seeing as a connection will time out, it should be sufficient doing this during advertising start, for example.

    2. You're correct. I guess it's just that my suggestion is to set the TX power in the advertising_start and not during init, so that the application can check what TX power it should use at the start of each advertisement.

    3. Please see this case for information on the TX power service.

    Best regards,

    Simon

Children
No Data
Related