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

BLE & BT 5.0 ble_app_uart

Hello All,

I made 2 custom boards, both mount a n52840 QIAAC0 chip.
I was able to program them using the "ble_app_uart peripheral" and "ble_app_uart_c" codes that I found in: "nRF5_SDK_15.1.0_a8c0c4d".


I can exchange packets between the 2 boards but I need to do it faster. I had thought about using the boards with the BT 5.0 but I was not able to change the code and use the PHY_2M.

-What should I change to use the PHY_2M, or is there any other nRF5_SDK_1....etc where the BT 5.0 is already implemented?

Another problem that I thought could slow down the communication is the "echo" of ble_app_uart_ peripheral ", that is, when I pass a 'packet' on the peripheral UART and I want to send it via bluetooth to the "central", this message is also rewritten on the UART of the device making me take an interrupt that I do not like to have.


-What should I change to avoid this problem?

What I wanna do is send a packet of 75 bytes. As I have tried, through 2 EVBoards nrf52840, almost all the examples that are on the Nordic site, from the ATT_MTU Throughput Example I understood (I hope good) that I'm able to achieve the max speed when I full the whole buffer, so I've changed this parameters in the code:

 BLE_GATT_ATT_MTU_DEFAULT=   78                   //was 23 but I did  --> 75 (my payload)+3

But if it is right is not enough.

Anyone could help me?

Thanks in advance

Parents
  • Hello,

    First, I'll just mention that SDK 15.1.0 was pulled, so I recommend that you download SDK15.2.0. There are just a few bug-fixes, so you shouldn't have to change anything else.

    All BLE links are by default created on 1M phy, so you can request a phy change. Just add this at the end of the BLE_GAP_EVT_CONNECTED event:

    
    ble_gap_phys_t const phys =
    {
        .rx_phys = BLE_GAP_PHY_2MBPS,
        .tx_phys = BLE_GAP_PHY_2MBPS,
    };
    err_code = sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys);
    APP_ERROR_CHECK(err_code);

    It takes a couple of seconds, but you can look after the BLE_GAP_EVT_PHY_UPDATE event (you can add this event to your ble_evt_handler, and print NRF_LOG_INFO("Phy updated"); in the event.

    The MTU is set in gatt_init, so you shouldn't need to touch BLE_GATT_ATT_MTU_DEFAULT. 

    /**@brief Function for initializing the GATT library. */
    void gatt_init(void)
    {
        ret_code_t err_code;
    
        err_code = nrf_ble_gatt_init(&m_gatt, gatt_evt_handler);
        APP_ERROR_CHECK(err_code);
    
        err_code = nrf_ble_gatt_att_mtu_periph_set(&m_gatt, NRF_SDH_BLE_GATT_MAX_MTU_SIZE); //NRF_SDH_BLE_GATT_MAX_MTU_SIZE == 247
        APP_ERROR_CHECK(err_code);
    }

    You can disable the UART printing on the central device (or both). Just comment out the app_uart_put() functions. These are definitely a bottleneck when you are testing throughput.

    Best regards,

    Edvin

Reply
  • Hello,

    First, I'll just mention that SDK 15.1.0 was pulled, so I recommend that you download SDK15.2.0. There are just a few bug-fixes, so you shouldn't have to change anything else.

    All BLE links are by default created on 1M phy, so you can request a phy change. Just add this at the end of the BLE_GAP_EVT_CONNECTED event:

    
    ble_gap_phys_t const phys =
    {
        .rx_phys = BLE_GAP_PHY_2MBPS,
        .tx_phys = BLE_GAP_PHY_2MBPS,
    };
    err_code = sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys);
    APP_ERROR_CHECK(err_code);

    It takes a couple of seconds, but you can look after the BLE_GAP_EVT_PHY_UPDATE event (you can add this event to your ble_evt_handler, and print NRF_LOG_INFO("Phy updated"); in the event.

    The MTU is set in gatt_init, so you shouldn't need to touch BLE_GATT_ATT_MTU_DEFAULT. 

    /**@brief Function for initializing the GATT library. */
    void gatt_init(void)
    {
        ret_code_t err_code;
    
        err_code = nrf_ble_gatt_init(&m_gatt, gatt_evt_handler);
        APP_ERROR_CHECK(err_code);
    
        err_code = nrf_ble_gatt_att_mtu_periph_set(&m_gatt, NRF_SDH_BLE_GATT_MAX_MTU_SIZE); //NRF_SDH_BLE_GATT_MAX_MTU_SIZE == 247
        APP_ERROR_CHECK(err_code);
    }

    You can disable the UART printing on the central device (or both). Just comment out the app_uart_put() functions. These are definitely a bottleneck when you are testing throughput.

    Best regards,

    Edvin

Children
No Data
Related