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

Sending 247 Bytes of data using NUS

Hi, I want to test sending multiple packets of data with each packet having the maximum possible size of 247 bytes. I am currently testing with nRF Connect app. When i try to send 20 Bytes of data it works fine, but when I am trying to send 21 Bytes of data the following event is not called at all :-

if (p_evt->type == BLE_NUS_EVT_RX_DATA) when i keep a breakpoint there.

Do let me know if there is some mistake done in the code. Also I have set NRF_SDH_BLE_GATT_MAX_MTU_SIZE to 247 bytes.

Is the nRF Connect app not capable of sending such data? Or do we need to create our own custom application?

I am using SES, nRF52840 and SDK 15.0.0.

Kind Regards,

Shrinidhi Bhat

  • Hi,

    The ble_app_uart example is configured to support a 247 byte MTU,  but it's not guaranteed that your phone will support it. The MTU size is negotiated with the central (phone) after connection, and you can see from the debug log what the effective data length ends up being (20 bytes is the default supported by all BLE chipsets). Do you have another phone that you know should support long MTU? 

    Best regards,

    Vidar

  • Hi Vidar,

    How do I know the phone supports larger MTU size? All the phones that we have here are equipped with BLE 5.0.

    The phone I am using currently is Poco F1 running on the latest Android.

    You said - " and you can see from the debug log what the effective data length ends up being 20 Bytes".

    Case 1: When my BLE_GATT_ATT_MTU_DEFAULT is 23 then I can see the following log

    -----------Data len is set to 0xF4(244)-----

    Case 2: I set my BLE_GATT_ATT_MTU_DEFAULT to 247 it does not even enter the if condition to display the the Log file

    ***if ((m_conn_handle == p_evt->conn_handle) && (p_evt->evt_id == NRF_BLE_GATT_EVT_ATT_MTU_UPDATED))**

    Hence By default I'm pretty sure my phone does support the 247 Bytes of MTU.

    NOTE:- I am currently using the ble_app_uart example in the ble_peripheral folder. Should I use the ble_central file instead?

    2nd Question is -> By following case ID 215355 I infer there is a bug in the nRF Connect application rather than the phone. Is the Bug fixed? And if not is the nRF Connect app opensource?

    Kind Regards,

    Shrinidhi Bhat

  • Hi Shrinidhi,

    Your phone supports long MTU if the "Data len is set to <bytes>" message says more than 20 bytes, so I'm not sure why you weren't able to receive more data in the callback. Can you try the pre-compiled hex and see if you get the same result ("\nRF5_SDK_15.0.0_a53641a\examples\ble_peripheral\ble_app_uart\hex\ble_app_uart_pca10056_s140.hex"? E.g., nrfjprog --program ble_app_uart_pca10056_s140.hex --chiperase -r. You won't be able to debug with the pre-compiled FW though, but you can use a serial client to verify that data gets received.

     I was not able to replicate this here. One packet  that I sent from nrf connect on iOS:

    2. This seems to be related to nRF connect for desktop, which is a completely different implementation compared to nRF connect on Android and iOS.  

    Kind regards,

    Vidar

Related