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
  • Hi,

    The code you have added is for including the TX power level that the beacon uses in the advertising packet. It does not change the actual TX power. The reason that the application does not work with these additions is most likely that the advertising packet was already full before you added this additional data field, generating an error when you run the application.

    To change the actual TX power level for the advertising, you should call sd_ble_gap_tx_power_set(). You can add this to the end of advertising_init() function to set +8 dBm output power:

    err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_adv_handle, 8);
    APP_ERROR_CHECK(err_code);

    Best regards,
    Jørgen

Reply
  • Hi,

    The code you have added is for including the TX power level that the beacon uses in the advertising packet. It does not change the actual TX power. The reason that the application does not work with these additions is most likely that the advertising packet was already full before you added this additional data field, generating an error when you run the application.

    To change the actual TX power level for the advertising, you should call sd_ble_gap_tx_power_set(). You can add this to the end of advertising_init() function to set +8 dBm output power:

    err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_adv_handle, 8);
    APP_ERROR_CHECK(err_code);

    Best regards,
    Jørgen

Children
No Data
Related