Decreased TX power and RSSI

Hello

I have 2 devices ,a central and a peripheral on a custom nRF52840 board

Using Zephyr SDK 2.5.0

The distance between the devices is 10.9 meters.
When  TX power on the peripheral is set to 0 the central receives packets with RSSI around -65 dBM

When the power on the peripheral is set to a negative value  -4, -8, -20 and even -40 the RSSI  received by the central does not change much - still hovers around -65

The function that sets the tx power is below. - taken from a Zephyr sample. The function succeeds
It is invoked as follows
set_tx_power(1,-8); where 1  is the advertising set handle

Any ideas why the RSSI is not affected even at very low TX?
Thank you

Andy
-------------------------------------------------------------------------

static int set_tx_power(uint16_t handle, int8_t tx_pwr_lvl)
{
    struct bt_hci_cp_vs_write_tx_power_level *cp;
    struct bt_hci_rp_vs_write_tx_power_level *rp;
    struct net_buf *buf, *rsp = NULL;
    int err;

    buf = bt_hci_cmd_create(BT_HCI_OP_VS_WRITE_TX_POWER_LEVEL,sizeof(*cp));

    if (!buf) {
        LOG_ERR("Unable to allocate command buffer");
        return -1;
    }
    cp = net_buf_add(buf, sizeof(*cp));
    cp->handle = sys_cpu_to_le16(handle);
    cp->handle_type = BT_HCI_VS_LL_HANDLE_TYPE_ADV;
    cp->tx_power_level = tx_pwr_lvl;

    err = bt_hci_cmd_send_sync(BT_HCI_OP_VS_WRITE_TX_POWER_LEVEL, buf, &rsp);

    if (!err) {
        rp = (void *)rsp->data;
        // Zephyr implementation returns no error if the tx power is invalid. Instead it just sets it to 0
        // We need to propagate the error up the call chain
        if(rp->selected_tx_power == tx_pwr_lvl){
            LOG_INF("Actual Tx Power: %d", rp->selected_tx_power);
        }else{
            LOG_ERR("Tx power not set! Value %d not supported by the radio, actual tx power:%d",tx_pwr_lvl,rp->selected_tx_power);
            errno = EINVAL; // so the caller can use strerror();
            err = -EINVAL; // Zephyr uses negative error codes
        }
    }else{
         uint8_t reason = (rsp ?    ((struct bt_hci_rp_vs_write_tx_power_level *) rsp->data)->status : 0);
        LOG_ERR("Set Tx power err: %d reason 0x%02x", err, reason);      
    }
    if(rsp){
        net_buf_unref(rsp);
    }
    return err;
}
Parents
  • Hi

    I will need to check. Normally if I have the need to adjust TX power I do with Kconfig option CONFIG_BT_CTLR_TX_PWR_ or  CONFIG_BT_CTLR_TX_PWR_ANTENNA can be used. 

    Could you try to add the get_tx_power function from here to see if it actually changes the tx power?

    Regards

    Runar

  • My code uses exact same function to get the power level so I'm pretty confident it changes

    My application requires dynamic TX power adjustment in some cases. It used to work in SDK's prior to 2.5.0 that I'm using now.
    I went back to v3.2.99-ncs2 ( not sure what SDK it maps to ) and at -40 TX the packets from the peripheral do not reach central - as expected. But with SDK 2.5.0 the central continues to receive them at  -64 dBM from 5.5 m 

  • Did some more testing 
    Same application code with different SDK's at ~5 m distance between central and peripheral

    3.2.99-ncs2

    TX     RSSI
    0        -76
    8        -65
    -8       -80
    -20     -87
    -40     -90

    SDK 2.4.0 and SDK 2.5.0

    TX     RSSI
    0        -71
    8        -71
    -8       -70
    -20      -71
    -40     -70

Reply Children
Related