set tx power level in nrf52810

Hello,

i am using nrf52810 and with my custom board and i want to know the tx power level of that and is it possible to change the range please let me know where to get and how to configure it??.

thank tou.

Parents
  • Hello,

    You can change they TX power level by using the sd_ble_gap_tx_power_set function. The valid TX power level configuration for the nRF52810 can be seen in its RADIO TXPOWER register documentation.

    Best regards,
    Karl

  • Hello ,

    thanks for the reply Karl, actually i am using ble_app_template example for advertising the sensor data for connectable beacon since here i have used this function already but i don't think so the value has changed. so for more details please check my code . here the cod

    at the starting i have added below line,
    
    static uint8_t  m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET;
    
    
    after this in advertising_init function i made this changes,
    
    static void advertising_init(void)
    {
        ret_code_t             err_code;
        ble_advertising_init_t init;
    
        memset(&init, 0, sizeof(init));
    
        int8_t tx_power_level = -40;
        sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV,m_adv_handle,tx_power_level);
    
    
        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);
    }
    
    e snippet that i have added ,

  • Please make sure to check the error code returned by the call to sd_ble_gap_tx_power_set - if you do not check the error code then you will have no way to know whether the function completed successfully or not.

    Furthermore, you should call the sd_ble_gap_tx_power_set after all of the SoftDevice configuration is already done, but before you start advertising.
    I would recommend moving the call to the very last line of the advertising_init function.

    Best regards,
    Karl

  • Hello,

    yeah, now i have added err_code in advertising_init function and i am printing the err_code value if its zero means its success right but i am getting  12239 like  some strange value so its not working advertising itself not working so what to do.?? 

    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);
        
        int8_t tx_power_level = -40;
        err_code=sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV,m_adv_handle,tx_power_level);
        printf("%d\r\n",err_code);
        APP_ERROR_CHECK(err_code);
    
    }
    
     

Reply
  • Hello,

    yeah, now i have added err_code in advertising_init function and i am printing the err_code value if its zero means its success right but i am getting  12239 like  some strange value so its not working advertising itself not working so what to do.?? 

    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);
        
        int8_t tx_power_level = -40;
        err_code=sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV,m_adv_handle,tx_power_level);
        printf("%d\r\n",err_code);
        APP_ERROR_CHECK(err_code);
    
    }
    
     

Children
Related