This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

long write samples

Hi All,

Are there any updated examples for nrf51822 for writing long charecteristics. My Application has to receive more than 20 bytes at a time and send over uart.

I am using experimental/ble_app_uart as starting point. I tried modifying the on_write function in service to check

if(p_evt_write->op == BLE_GATTS_OP_EXEC_WRITE_REQ_NOW) {
if ((p_evt_write->handle == p_nus->tx_handles.value_handle)) { p_nus->data_handler(p_nus, p_evt_write->data, p_evt_write->len); } else { // Do Nothing. This event is not relevant to this service. } }

But not getting anything on console. Without any modification app works fine for 20 bytes write. Even If send more than 20 bytes from android app it prints only 20 bytes.

Also my app requirement is to receive variable length writes from client to server.

What/Where changes needs to be made to make it working for writing more than 20 bytes ?

Am new to BLE development. Trying to learn by doing.

Thanks in Advance

Parents
  • I think you might be confusing long writes and long MTU.

    Long writes, also called "Reliable writes" or "Queued Writes", allows you to reliably and simultaneously write multiple <=20-byte chunks to a single or multiple characteristic(s)/descriptor(s). It does not allow you to transfer more data per connection event than other functions. (There are some restrictions in peer memory, and you are not allowed to have overlapping regions.) See here for some MSCs.

    If you want to send more than 20 bytes, you will have to break it down into chunks. If you need to write all the chunks at the same time (i.e. you want to update some data display that continuously reads more than 20 bytes of data each update) you can use reliable writes. If you want to enable/disable multiple CCCDs you can use reliable writes. However, if you need to send more than 20 bytes per packet, that is not currently possible with the Nordic SoftDevices.

  • I have increased MAX_TX_CHAR_LEN ..also added BLE_EVT_USER_MEM_REQUEST an passed pointer to mem buffer of size 100 ...changed ble_uart_code ..but still I see only 20 bytes on uart console output.

    Do I need to send data from peer (android app in chunks of 20 bytes ) .. for this to work properly...I have created a android for sending data.

Reply
  • I have increased MAX_TX_CHAR_LEN ..also added BLE_EVT_USER_MEM_REQUEST an passed pointer to mem buffer of size 100 ...changed ble_uart_code ..but still I see only 20 bytes on uart console output.

    Do I need to send data from peer (android app in chunks of 20 bytes ) .. for this to work properly...I have created a android for sending data.

Children
No Data
Related