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

[nRF52840 SDK 16.0.0] ble beacon example change TX power level

Hi all,

I'm using the "ble_beacon_app" example from the SDK 16.0.0 with the nRF52840 DK. I would like to change the TX power level.

In main.c function, I tried to change the advertising_init() by adding the following code:

    int8_t tx_power_level = 8;
    advdata.p_tx_power_level = &tx_power_level;

I get no error by compiling the project, but the application doesn't work and I cannot see any device from the nRF connect App scanner.

Could you please help me where is the problem? Thank you in advance

Parents
  • I tried to put this code at the end of the advertising_init function, to get the lowest throughput for advertising, which should be 125 kbps (I saw it is supported for advertising non-connectable mode in the latest version of s140):

    //set PHY mode: 
        ble_gap_phys_t const myPhys =
                {
                    .rx_phys = BLE_GAP_PHY_CODED, //lowest datarate
                    .tx_phys = BLE_GAP_PHY_CODED,
                };
    
        err_code = sd_ble_gap_phy_update(m_adv_handle, &myPhys);
        APP_ERROR_CHECK(err_code);

    I get no errors from the compiler, but the application doesn't work.

    I would like to set the 125 kbps data rate to achieve the long-range mode for advertising.

    Any suggestions? Thank you in advance!!

Reply
  • I tried to put this code at the end of the advertising_init function, to get the lowest throughput for advertising, which should be 125 kbps (I saw it is supported for advertising non-connectable mode in the latest version of s140):

    //set PHY mode: 
        ble_gap_phys_t const myPhys =
                {
                    .rx_phys = BLE_GAP_PHY_CODED, //lowest datarate
                    .tx_phys = BLE_GAP_PHY_CODED,
                };
    
        err_code = sd_ble_gap_phy_update(m_adv_handle, &myPhys);
        APP_ERROR_CHECK(err_code);

    I get no errors from the compiler, but the application doesn't work.

    I would like to set the 125 kbps data rate to achieve the long-range mode for advertising.

    Any suggestions? Thank you in advance!!

Children
  • Today I also tried to update the parameters m_adv_params of ble_gap_adv_params_t data type, which is declared at the beginning of main.c, by adding in advertising_init() function the last line of the following code:

        m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
        m_adv_params.p_peer_addr     = NULL;    // Undirected advertisement.
        m_adv_params.filter_policy   = BLE_GAP_ADV_FP_ANY;
        m_adv_params.interval        = NON_CONNECTABLE_ADV_INTERVAL;
        m_adv_params.duration        = 0;       // Never time out.
        m_adv_params.primary_phy     = BLE_GAP_PHY_CODED; // added this line,
                                                         // trying to set phy to 125 kbps

    But, even in this case, the application doesn't work. By building and debugging, the app_error_fault_heandler is called.

Related