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

How to set sending power of NRF52810 with SDK15.0

Hi,

I want to set sending power(+4dBm) of NRF52810/NRF52832 with SDK 15.0.

Now,i  find i should use  the order of sd_ble_gap_tx_power_set(uint8_t role, uint16_t handle, int8_t tx_power));

But , i donn't the meaning of second parameter.

List as follows by SDK15.0:

* @param[in]     handle                     The handle parameter is interpreted depending on role:
* - If role is @ref BLE_GAP_TX_POWER_ROLE_CONN, this value is the specific connection handle.
* - If role is @ref 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
* @ref ble_gap_adv_properties_t::include_tx_power set.
* - For all other roles handle is ignored.

Now,  i will make a beacon and  i set it as sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV,0,4);

It is right?

If the role is BLE_GAP_TX_POWER_ROLE_CONN, how to set the second parameter.

Parents
  • I'm trying to do the same thing for a nRF52810 using SD 112 v6.0.0.  Can you provide details in how to set m_adv_handle?  I'm confused why this is uint16_t as it seems like it should be an address for the advertising data structure.  How did you define this?

    Thanks,  Max

  • Hello Max,

     

    I am not quite sure I follow. The m_adv_handle is set the same way for the s112 on the nRF51810 as for the s132 on the nRF52832. The m_adv_handle is an uint16_t, and not uint8_t.

     

    The advertising handle, m_adv_handle is set in the sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params), which is usually called in advertising_init() in most of our examples in the SDK.

     

    Do you get any issues while setting this?

     

    Best regards,

    Edvin

  • Edvin,

    Thanks.  What you described is not quite what I see in my SDK example.  I'm still not seeing how to set the adv_handle correctly in this context.  I've inserted the advertising_init() below.  This comes from the bluetoothds_template.

    Max

     

    static void advertising_init(void)
    {
        ret_code_t    err_code;
        ble_advertising_init_t init;
    
    
        memset(&init, 0, sizeof(init));
    
        init.advdata.name_type               = BLE_ADVDATA_FULL_NAME;
        init.advdata.include_appearance      = true;
        init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
        init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        init.advdata.uuids_complete.p_uuids  = m_adv_uuids;
    
        init.config.ble_adv_fast_enabled   = true;
        init.config.ble_adv_fast_interval  = APP_ADV_INTERVAL;
        init.config.ble_adv_fast_timeout   = APP_ADV_DURATION;
    
        init.evt_handler = on_adv_evt;
    
        err_code = ble_advertising_init(&m_advertising, &init);
        APP_ERROR_CHECK(err_code);
    
        ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    
    		// Set transmit power to 4 dBm
    		err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV,????????,4);
    		APP_ERROR_CHECK(err_code);
    		
    }
    

  • hello,

    I used the example of beacon.

    I think it should be like this:

    ........................................................................................

    /** @brief Advertising set handle not set. */
    #define BLE_GAP_ADV_SET_HANDLE_NOT_SET (0xFF)

    static uint8_t              m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; /**< Advertising handle used to identify an advertising set. */

    .......................................................................................

    advertising_init();
    uint8_t err_adv=sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV,m_adv_handle,+4); //after advertising_init();
    advertising_start();

    Best  regards,

    liu

  • It is correct, as @liu says. You need to use the advertising handle.

    The advertising_init is set up a little different in the Beacon example, and in the regular ble_peripheral examples.

    You can find the advertising example in the m_advertising struct.

     

    sd_ble_gap_tx_power_set() must be after ble_advertising_init() I am not 100% sure whether it has to be after ble_advertising_conn_cfg_tag_set(), but you will quickly find out.

     

    It should look something like this:

    ble_advertising_init(...);
    
    ble_advertising_conn_cfg_tag_set(...);
    
        err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_advertising.adv_handle, 4);
        APP_ERROR_CHECK(err_code);

Reply
  • It is correct, as @liu says. You need to use the advertising handle.

    The advertising_init is set up a little different in the Beacon example, and in the regular ble_peripheral examples.

    You can find the advertising example in the m_advertising struct.

     

    sd_ble_gap_tx_power_set() must be after ble_advertising_init() I am not 100% sure whether it has to be after ble_advertising_conn_cfg_tag_set(), but you will quickly find out.

     

    It should look something like this:

    ble_advertising_init(...);
    
    ble_advertising_conn_cfg_tag_set(...);
    
        err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_advertising.adv_handle, 4);
        APP_ERROR_CHECK(err_code);

Children
Related