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.

  • If you choose to let the stack handle the memory for you, you will not be able to see the individual chunks coming in until the execute happens. Then all of them will arrive in a single write event. If you let your application handle each request, they will arrive as BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST which you have to authorize one by one. You can choose between these behaviors by giving a mem block in mem_reply (stack handled) or NULL (app handled). The MSCs for the APP handled variant can be found here: devzone.nordicsemi.com/.../a00856.html

Reply
  • If you choose to let the stack handle the memory for you, you will not be able to see the individual chunks coming in until the execute happens. Then all of them will arrive in a single write event. If you let your application handle each request, they will arrive as BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST which you have to authorize one by one. You can choose between these behaviors by giving a mem block in mem_reply (stack handled) or NULL (app handled). The MSCs for the APP handled variant can be found here: devzone.nordicsemi.com/.../a00856.html

Children
No Data
Related