Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Changing the transmission power on ble_app_att_mtu_throughput example

Hi,

I have searched Devzone for changing the transmission power; even though there were similar issues related to mine but at the end, It did not help me.

I am evaluating the new PHYs of BLE 5 in an indoor environment at the university.  

I tried to use the following codes:

ret_code_t err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_SCAN_INIT, BLE_CONN_HANDLE_INVALID, RADIO_TX_POWER); ( inside scan_start function)

err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN, BLE_CONN_HANDLE_INVALID, RADIO_TX_POWER); ( I used this one inside 

ble_evt_handler function under BLE_GAP_EVT_CONNECTED.)

err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_adv_handle, RADIO_TX_POWER); (I used this one inside advertising_start function)

I get fatal error!! 

I know there is a long range example but I really want to use the throughput example with modified transmission power. 

I do not know in which part I am doing wrong!!! Any help will be appreciated. 

Br,

Ben

Parents
  • Hi Joakim,

    Yes, I have seen that answer. It did not help. It is strange. Perhaps I am doing some silly mistake.

    I have compared the throughput example and the long-range example. I can not figure it out why it throws Fatal error. 

    These are the places that I have used "sd_ble_gap_tx_power_set" functtion in the code: 

    ....

    case BLE_GAP_EVT_CONNECTED:
    err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN, BLE_CONN_HANDLE_INVALID, RADIO_TX_POWER);

    on_ble_gap_evt_connected(p_gap_evt);
    sd_ble_gap_rssi_start(p_ble_evt->evt.gap_evt.conn_handle, 1, 1); //added by _OP
    APP_ERROR_CHECK(err_code);
    break;

    .....

    /**@brief Function for starting advertising. */
    static void advertising_start(void)
    {
    NRF_LOG_INFO("Starting advertising.");

    ret_code_t err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_adv_handle, RADIO_TX_POWER);
    APP_ERROR_CHECK(err_code);

    bsp_board_led_on(SCAN_ADV_LED);
    err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);
    APP_ERROR_CHECK(err_code);

    }

    ........

    /**@brief Function for starting the scanning. */
    static void scan_start(void)
    {
    NRF_LOG_INFO("Starting scanning.");
    ret_code_t err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_SCAN_INIT, BLE_CONN_HANDLE_INVALID, RADIO_TX_POWER);
    APP_ERROR_CHECK(err_code);
    bsp_board_led_on(SCAN_ADV_LED);

    err_code = nrf_ble_scan_start(&m_scan);
    APP_ERROR_CHECK(err_code);
    }

    ........

    Thanks for the help.

    Br,

    Ben

  • Hi,

    I resolved the issue by changing:

    "

    case BLE_GAP_EVT_CONNECTED:
    err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN, BLE_CONN_HANDLE_INVALID, RADIO_TX_POWER);
    on_ble_gap_evt_connected(p_gap_evt);
    break;

    "

    to

    "

    case BLE_GAP_EVT_CONNECTED:
    m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
    err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN, m_conn_handle, RADIO_TX_POWER);
    APP_ERROR_CHECK(err_code);

    on_ble_gap_evt_connected(p_gap_evt);

    break;

    "

    The problem was in passing the correct connection handle to "sd_ble_gap_tx_power_set" function in connection state.

    Br,

    Ben

Reply
  • Hi,

    I resolved the issue by changing:

    "

    case BLE_GAP_EVT_CONNECTED:
    err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN, BLE_CONN_HANDLE_INVALID, RADIO_TX_POWER);
    on_ble_gap_evt_connected(p_gap_evt);
    break;

    "

    to

    "

    case BLE_GAP_EVT_CONNECTED:
    m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
    err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN, m_conn_handle, RADIO_TX_POWER);
    APP_ERROR_CHECK(err_code);

    on_ble_gap_evt_connected(p_gap_evt);

    break;

    "

    The problem was in passing the correct connection handle to "sd_ble_gap_tx_power_set" function in connection state.

    Br,

    Ben

Children
Related