Write long characteristics

Team, 

I am using nrf52810, sdk 17, sd112. 

I have setup a write characteristics, to receive some long data ( 64 bytes)

// write char
memset(&add_char_params, 0, sizeof(add_char_params));
add_char_params.uuid = LBS_UUID_WR_CHAR;
add_char_params.uuid_type = p_lbs->uuid_type;
add_char_params.init_len = 64;
add_char_params.max_len = 64;
add_char_params.char_props.read = 0;
add_char_params.char_props.write = 1;
add_char_params.is_value_user = true;

add_char_params.read_access = SEC_OPEN;
add_char_params.write_access = SEC_OPEN;

characteristic_add(p_lbs->service_handle, &add_char_params, &p_lbs->wr_char_handles);

I have set my MTU to 70

When I use NRF connect android app and issue small data (8-12 bytes), it arrives on the nrf52810. 

When I send long data anything longer than 25 bytes, it does not arrive. 

My questions are: 

1. Where is the memory for holding incoming characteristics data? 

does this flag control its location?  add_char_params.is_value_user = true;  the documentation reads :   /**< Indicate if the content of the characteristic is to be stored in the application (user) or in the stack.*/

In some examples I have seen this  attr_md.vloc = BLE_GATTS_VLOC_STACK;

how are the two related?

2. What is the purpose of  sd_ble_user_mem_reply

The documentation reads: 

p_block Pointer to a user memory block structure or NULL if memory is managed by the application.

3. who initiates the MTU exchange? is it sufficient to set the MTU on the NRF52 to 70 bytes? Does the android nrf connect request a larger MTU? 

Any step by step guidance on how to receive large data would be much appreciated. 

Regards, 

Hari 

NOTE: I WAS ABLE TO GET THIS WORKING

Upon connection from android app, I made the nrf52 request mtu of 70 to android app. After that transfer is happening properly. 

Please confirm I have done the right thing. 

  • Hi

    1. Are you sure the nRF52810 application is set up to support higher MTU sizes than 23 bytes (which is the standard non-extended maximum size). This blog post has a great explanation on how to increase throughput and how to set up larger MTU sizes for nRF devices.

    2. sd_ble_user_mem_reply is used to provide a user memory block, and can only be used as a response to a BLE_EVT_USER_MEM_REQUEST event.

    3. If you're working with an Android device and the nRF Connect for Android app you should be able to set other MTU sizes from the ... menu next to the name of the connected device, which is what should initiate an MTU exchange once connected. It's also possible to set this up on the peripheral side if you want, but the central device will have to support the suggested value to "allow" it. There is usually an MTU exchange right after devices have connected to one another to find values they both support.

    Best regards,

    Simon

Related