nRF5 SDK is not maintained anymore
More Info: Consider nRF Connect SDK for new designs

Data field too short in BLE over Uart

Hello everyone,

I am working with the SDK v17.1.0 with the DK nRF52832 with the examples of ble_app_uart and ble_app_uart_c.

I want to send an array "data_array" of uint8_t from one "slave" nRF52832 to one "master" nRF52832. However, the size of data_array is 40 bytes. 

When I tried to find where the maximum size of data that can be send is, I encountered some macros that could helped me:

 - m_ble_nus_max_data_len : sets the maximum length of a data that can be send over ble nus

 - BLE_GATT_ATT_MTU_DEFAULT  23: sets the Maximum Transmission Unit (MTU) is the maximum length of an ATT packet

- BLE_GAP_DATA_LENGTH_DEFAULT 27 : sets the stack's default data length.

So I tried to increase these values and be able to send more data but I can only send 26 bytes and the master can only process 15 bytes correctly as shown in the following picture. 

Could you help me with that?

Thank you all

Parents
  • If you are using the default example (without modifications) you should not need to do anything to allow large packets to be sent.

    Just wait for the NRF_BLE_GATT_EVT_ATT_MTU_UPDATED event in the gatt_evt_handler(), which should give you the maximum data size in the m_ble_nus_max_data_len parameter (=244bytes).

    Once that has occured you can send data of up to 244bytes by calling ble_nus_data_send().

    Best regards,
    Kenneth

  • Hello, thanks for the answer!

    I put the values of the macros back except that I increased the RAM_SIZE and moved the RAM_START, and I worked with that configuration.

    Just wait for the NRF_BLE_GATT_EVT_ATT_MTU_UPDATED event in the gatt_evt_handler(), which should give you the maximum data size in the m_ble_nus_max_data_len parameter (=244bytes).

    As I increased the RAM, I have m_ble_nus_max_data_len = 397bytes. (as seen in the console in the picture)

    Having m_ble_nus_max_data_len set, I try to send my 40 bytes but only 26 bytes are sent and I enter a infinity loop. 

    I think it is because the GAPlayer in the BLE technology only allows to send 27 bytes, but I am not sure. Do you have an opinion on that? 

    Thank you

Reply
  • Hello, thanks for the answer!

    I put the values of the macros back except that I increased the RAM_SIZE and moved the RAM_START, and I worked with that configuration.

    Just wait for the NRF_BLE_GATT_EVT_ATT_MTU_UPDATED event in the gatt_evt_handler(), which should give you the maximum data size in the m_ble_nus_max_data_len parameter (=244bytes).

    As I increased the RAM, I have m_ble_nus_max_data_len = 397bytes. (as seen in the console in the picture)

    Having m_ble_nus_max_data_len set, I try to send my 40 bytes but only 26 bytes are sent and I enter a infinity loop. 

    I think it is because the GAPlayer in the BLE technology only allows to send 27 bytes, but I am not sure. Do you have an opinion on that? 

    Thank you

Children
No Data
Related