Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Is it necessary handle BLE_EVT_USER_MEM_REQUEST, respectivly is it required to support prepared writes?

Until lately, I have never used characteristics longer than the 20 Bytes and if the length of application data was longer, I would fragment it on the application layer.

Recently, I started experimenting with increasing the Att MTU size and the link layer PDU size. To really be able to make use of this, it is of course useful if characteristic length is increased to accommodate the larger MTU of up to 247 Bytes, i.e. I increased characteristic size to 244 Bytes variable length characteristic.

I then noticed, that if I connect to the device using an older smart device (e.g. iPad 4, using Light Blue), a write of more than 20 Bytes of data will result in a prepared write request being transmitted and thus, the Softdevice will emit BLE_EVT_USER_MEM_REQUEST. For the time being, I do not see any benefits in supporting prepared writes - I'm planning to make use of the higher characteristic length only if an increased MTU size is actually used during the connection.

  • Do I have to handle BLE_EVT_USER_MEM_REQUEST? What happens if I do not handle this event?
  • If I handle the event by calling sd_ble_user_mem_reply with p_block == NULL, I will receive a BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST. How do I have to respond to this request if I don't want to support prepared writes?
  • Would it be easier to just support prepared writes?
  • What happens if I pass a buffer that is too small to sd_ble_user_mem_reply?

Thank you for your response,

-mike

Parents
  • Hi,

    I'm not sure how you can avoid implementing mechanisms for prepared writes if you want to enable long MTUs. It sounds like you already know, but older devices might not support longer MTUs, and you have to be prepared for that. Furthermore, you will have to initialize your attribute table and BLE stack before you connect to a peer device. I.e. you can't decide whether the BLE stack uses long or short characteristics after you have connected with a peer and figured out how long MTUs it supports. Maybe you can work something out on the application layer anyway. Do you have a plan in mind?

    I'll have to get back to you with further answers next week. 

  • Hi Martin,

    Thanks for your response. The idea here is to do serial data transfer using write w/o response and notifications. Since we are able to know the supported MTU size on the current BLE-connection, we should be able to use regular write w/o response and notifications of a length corresponding to this MTU size. So we will at most write MTU-size - 3 Bytes to the characteristic - even if the characteristic would be longer. Therefore, from my understanding, we don't technically need to support prepared writes.

    Best regards,

    -mike

  • Ok, that makes sense. What SDK and Softdevice versions are you using?

  • For now mainly with SDK14 and S132 5.x. But I'm interested in other Softdevices and SDKs as well. Some of our relevant projects are running on S132 4.x, we may upgrade our platform to SDK15/S132 6.x at some point and there might be a need to support S112, too.

Reply Children
No Data
Related