This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Large “virtual” read only characteristic?

I would like to create a large “virtual” read only characteristic that does not fully exist in memory. I understand that large characteristics are transferred in chunks of about 22 bytes at a time and I would like to dynamically control the contents of that chunk.

For example: I have a large dataset that resides on an external storage device (i2c eeprom). I have a small 22 byte buffer exists in RAM (can be larger if needed). The client reads the large value in 22 byte chunks by specifying an offset. I want to copy 22 bytes from external storage into the RAM buffer. Then the S110 SD transfers that 22 byte chunk from RAM to the client. So the 22 byte RAM buffer acts as a “window” into the large external storage.

It seems pretty straight forward but I have not been able to get this to work.

I have tried using the BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event to set the value of the data chunk dynamically but it always copies the new data into the characteristic's value at the offset and length specified in the reply. This method requires the characteristic's value buffer to be large enough to hold the entire external dataset. But the external dataset cannot fit into RAM (that's why it is external). I tried setting the ble_gatts_rw_authorize_reply_params_t “update” field to zero but that does not work.

I want to be able to set only the 22 bytes that are being transferred without having a RAM buffer that is the full size of the “virtual” dataset. Since only 22 bytes are actually used during each read operation only 22 bytes should be needed.

Is there a way to accomplish this task using the Nordic SDK?

Parents
  • I found that as of SDK 8.0, a "virtual characteristic" is not supported.

    Instead, the characteristic MUST be backed in full by stack or user memory. In cases where the value is stored offline or calculated on the fly, it MUST be copied to the characteristic's value memory. It can NOT simply be returned via the BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST reply.

    If the characteristic is larger than the max allowed (about 500 bytes), it can be "streamed" to the client via notifications or indications.

    A large characteristic can also be accessed in chunks of about 500 bytes at a time using one characteristic to specify the chunk index and another to represent the 500 byte data chunk. For example, if chunk index is 0 then the data chunk represents the first 500 or so bytes of a larger dataset; if chunk index is set 1 then the data chunk represents bytes 500-999, etc.

    It would be nice if a future SDK release could allow the BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST read reply to return the data on the fly instead of requiring the data to be stored.

  • Hi machine,

    Please aware that the characteristic with bigger value size than 20 bytes, when transmitting via long read or long write will still be split into chunks of 18 bytes payload and send over the link. The largest payload size on link layer packet is still 23 bytes (5 bytes for opcode, handle, and offset)

    It's just the softdevice do the pay load split processing for the application. But only long write and long read support this, not notification/indication.

    I don't really understand your need of having sd_ble_gatts_rw_authorize_reply() command that don't update the value of the characteristic. If you want to have a "virtual" characteristic ( that has the size of more than 20 bytes for example) why do you need to worry if the data is updated into the value of the real characteristic on the server ?

Reply
  • Hi machine,

    Please aware that the characteristic with bigger value size than 20 bytes, when transmitting via long read or long write will still be split into chunks of 18 bytes payload and send over the link. The largest payload size on link layer packet is still 23 bytes (5 bytes for opcode, handle, and offset)

    It's just the softdevice do the pay load split processing for the application. But only long write and long read support this, not notification/indication.

    I don't really understand your need of having sd_ble_gatts_rw_authorize_reply() command that don't update the value of the characteristic. If you want to have a "virtual" characteristic ( that has the size of more than 20 bytes for example) why do you need to worry if the data is updated into the value of the real characteristic on the server ?

Children
No Data
Related