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

How to set Radio Power for nRF52840 for (Mesh, Zigbee, BLE)

Hi i used nRF52840 Preview-DK and i try many example with SDK provided.

the problem is the range of transmission too short . can you help how to set power transmission of this module ? for zigbee, BLE Mesh, Thread...

thanks

Parents Reply Children
  • Thank you longrain

    i follow your code ,i can compile without error. may i know Tx power of Zigbee and BLE the same ?

    i see command sd_ble_gap_tx_power_set(); for BLE but i don't know where can i add this command 

    When i add this command to my code it's error 

    Thank

  • Tread and Zigbee SDK2.0:

    In ble_gap.h,you can find the follow introduction:

    /**@brief Set the radio's transmit power.
    *
    * @param[in] role The role to set the transmit power for, see @ref BLE_GAP_TX_POWER_ROLES for
    * possible roles.
    * @param[in] handle The handle parameter is interpreted depending on role:
    * - If role is @ref BLE_GAP_TX_POWER_ROLE_CONN, this value is the specific connection handle.
    * - If role is @ref BLE_GAP_TX_POWER_ROLE_ADV, the advertising set identified with the advertising handle,
    * will use the specified transmit power, and include it in the advertising packet headers if
    * @ref ble_gap_adv_properties_t::include_tx_power set.
    * - For all other roles handle is ignored.
    * @param[in] tx_power Radio transmit power in dBm (see note for accepted values).
    *
    * @note Supported tx_power values: -40dBm, -20dBm, -16dBm, -12dBm, -8dBm, -4dBm, 0dBm, +2dBm, +3dBm, +4dBm, +5dBm, +6dBm, +7dBm and +8dBm.
    * @note The initiator will have the same transmit power as the scanner.
    * @note When a connection is created it will inherit the transmit power from the initiator or
    * advertiser leading to the connection.
    *
    * @retval ::NRF_SUCCESS Successfully changed the transmit power.
    * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
    * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Advertising handle not found.
    * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
    */
    SVCALL(SD_BLE_GAP_TX_POWER_SET, uint32_t, sd_ble_gap_tx_power_set(uint8_t role, uint16_t handle, int8_t tx_power));

    enum BLE_GAP_TX_POWER_ROLES
    {
    BLE_GAP_TX_POWER_ROLE_ADV = 1, /**< Advertiser role. */
    BLE_GAP_TX_POWER_ROLE_SCAN_INIT = 2, /**< Scanner and initiator role. */
    BLE_GAP_TX_POWER_ROLE_CONN = 3, /**< Connection role. */
    };

    There are three roles when you call "sd_ble_gap_tx_power_set".

    So according to the role,call "sd_ble_gap_tx_power_set" after adv_init or scan_init .

    And  use "BLE_GAP_TX_POWER_ROLE_CONN " when connected.

    Maybe like this:

    void test_set_tx_power(void)
    {
    uint32_t err_code;

    if(m_conn_handle != BLE_CONN_HANDLE_INVALID)
    {
    err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN ,m_conn_handle,8);
    APP_ERROR_CHECK(err_code);
    }
    else
    {

    //BLE_GAP_TX_POWER_ROLE_ADV  for peripheral advertising.
    err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_SCAN_INIT,0,8);
    APP_ERROR_CHECK(err_code);
    }

    nrf_802154_tx_power_set(8);//
    }

    This is the way I am using for test . Hope it can help you.

  • i see command sd_ble_gap_tx_power_set(); for BLE but i don't know where can i add this command 

    That's covered in the link I posted earlier!

Related