Setting advertising transmission power

i have nrf52832 sdk vr 17.0.2. i want to set transmission power of advertising packet. pls assist

Parents
  • Hello,

    You can set this using the sd_ble_gap_tx_power_set function directly.
    As mentioned in the function API Reference you will need to enable include_tx_power for it to be included in your advertising packet.

    Best regards,
    Karl

  •  */
    static void advertising_init(){
        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_LIMITED_DISC_MODE;
       
    		init.srdata.uuids_more_available.uuid_cnt=sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    		init.srdata.uuids_more_available.p_uuids =m_adv_uuids;
        init.config.ble_adv_whitelist_enabled = false;
        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);
        uint32_t err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_advertising.adv_handle, 4); 
        APP_ERROR_CHECK(err_code);
        ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    		
    		
    		
    		
    		
    }

    is it how shall it work?? i have added

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

    pls chek

  • Yes, thought you do not need to have the type declaration there since you've already declared it at the beginning of your function.
    Are you not seeing an increase in the RSSI when you've added this line?

    Best regards,
    Karl

  • yes, i found that increasing power in adv increases the RSSI. 

    Kindly tell by default what is the power used if i dont add the sd_ble_gap_tx_power_set(). 

    Also, what is the default PHY used

  • Ridhi said:
    yes, i found that increasing power in adv increases the RSSI. 

    Great, I'm happy to hear that it worked as expected.

    Ridhi said:

    Kindly tell by default what is the power used if i dont add the sd_ble_gap_tx_power_set(). 

    Also, what is the default PHY used

    The default txpower is +0, and the BLE advertising library default to using 1M PHY if no other phy is specified for the advertising mode, this happens in the following section of ble_advertising_start

    ..
        // Use 1MBIT as primary phy if no phy was selected.
        if (phy_is_valid(&p_advertising->adv_modes_config.ble_adv_primary_phy))
        {
            p_advertising->adv_params.primary_phy = p_advertising->adv_modes_config.ble_adv_primary_phy;
        }
        else
        {
            p_advertising->adv_params.primary_phy = BLE_GAP_PHY_1MBPS;
        }
    ..


    Best regards,
    Karl

  • thnku Karl,

    wud like to know that min how much time an advertising event takes. Like  adv interval can range from 20 ms to 10.24s. i want to know min an event take how much time 

Reply Children
Related