Enabling the 2MB Phy to increase nus throughput : nRF connect sdk 2.4.0

Hi,

  We have developed the application based on NRF52840 using nrf Connect SDK 2.4.0 in which we are transferring the data via nus to ble uart,

 Everything is working fine but the data transfer rate is very slow. 

I need to increase the data transmission speed, is there any way to do increase it,

On devzone couple of blogs say to change the PHY to 2MB instead of 1MB which increase the data rate by double.

Could you please let us know how can i make the configuration from 1MB PHY to 2MB PHY.

1. What are the thing need to be added in the prj.cfg file to convert 1MB PHY to 2MB PHY

2. How we can verify if the PHY has been updated using nrf connect tool.

Regards,
Ram

  • Hi Ram,

    To use 2 Mbps PHY you can add the following configs:

    CONFIG_BT_CTLR_PHY_2M=y
    CONFIG_BT_AUTO_PHY_UPDATE=y

    To see what happens in the log you can also add CONFIG_BT_USER_PHY_UPDATE=y so that you will get a callback when the PHY is updated. Then you could also make the following changes to main.c (from the central in this case) to get the PHY update printed:

    diff --git a/samples/bluetooth/central_uart/src/main.c b/samples/bluetooth/central_uart/src/main.c
    index be4c1f0ae..5d869364f 100644
    --- a/samples/bluetooth/central_uart/src/main.c
    +++ b/samples/bluetooth/central_uart/src/main.c
    @@ -437,10 +437,29 @@ static void security_changed(struct bt_conn *conn, bt_security_t level,
            gatt_discover(conn);
     }
     
    +static const char *phy2str(uint8_t phy)
    +{
    +       switch (phy) {
    +       case 0: return "No packets";
    +       case BT_GAP_LE_PHY_1M: return "LE 1M";
    +       case BT_GAP_LE_PHY_2M: return "LE 2M";
    +       case BT_GAP_LE_PHY_CODED: return "LE Coded";
    +       default: return "Unknown";
    +       }
    +}
    +
    +static void le_phy_updated(struct bt_conn *conn,
    +                          struct bt_conn_le_phy_info *param)
    +{
    +       LOG_INF("LE PHY updated: TX PHY %s, RX PHY %s\n",
    +              phy2str(param->tx_phy), phy2str(param->rx_phy));
    +}
    +
     BT_CONN_CB_DEFINE(conn_callbacks) = {
            .connected = connected,
            .disconnected = disconnected,
    -       .security_changed = security_changed
    +       .security_changed = security_changed,
    +       .le_phy_updated = le_phy_updated,
     };
     
     static void scan_filter_match(struct bt_scan_device_info *device_info,

    Note that to improve the throughput you may also want to make other changes, like increase the ATT MTU. You can refer to the Throughput sample implementation (particularly prj.conf) for that and other throughput related changes you may want to make).

    Einar

  • Hi Einar,

    Thanks a lot for quick response. 

    Yes i have taken care of ATT MTU configuration and i am able to receive 240 bytes of data , there is no issue with data 

    Currently my device is a peripheral device where it need to communicate with the mobile application using nus service.

    Current drawback back is the data transfer rate is too slow, and need to improve the speed by increasing the phy to 2MB ..

    1. can Phy changing to 2MB improves the nus data transmission speed.?

    2. How do i monitor in the mobile nrf app to check if the phy layer got changed ..?

    also i tried to do the configuration as  suggested, but i am gettign the dependencies error as shown below

    Please let me know should i enable all the depencies which is mentioned in the error

    1. CONFIG_BT_PHY_UPDATE=y

    2. CONFIG_BT_CONN=y

    3. CONFIG_BT_HCI_HOST=y

    4. CONFIG_BT_RPC_STACK=y

    Regards.

    Ram

  • Hi Ram,

    Ramachandra Reddy said:
    also i tried to do the configuration as  suggested, but i am gettign the dependencies error as shown below

    That is odd, when I tested the NUS smaples sample from NCS 2.4 with just the described change on my end CONFIG_BT_PHY_UPDATE got automatically set. But if not, you can set it manually  (CONFIG_BT_PHY_UPDATE=y). The same with any other dependencies.

    Ramachandra Reddy said:
    1. can Phy changing to 2MB improves the nus data transmission speed.?

    That will double the (theoretical) capacity of the Bluetooth link, so assuming you also do other adjustments (longer packet, larger buffers so you can send many packet per connection event etc), then yes. But if the bottle-neck is somewhere else (due to missing other relevant configs as mentioned, or for instance if you use physical UART), then it might not help.

    Ramachandra Reddy said:
    2. How do i monitor in the mobile nrf app to check if the phy layer got changed ..?

    You cannot see that (at lest not on iOS). So I would suggest checking with a sniffer or logging as I suggested in my initial post (that diff is for the NUS central sample but you can use the exact same method with the peripheral as well).

    Einar

  • Hi Thorsrud,

      Thanks for the support, please let me know how to close the ticket

      

Related