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
  • Many ways.

    Easiest one is to specify the data as being in user memory not on the stack, you can then point directly to your data and it will read it right out of the memory.

    Alternately if you specify the characteristic as in user memory and use the RW authorize request, it will send the 22 bytes you give it out as the reply and won't try to copy it anywhere.

    I also don't remember what the 'update' flag in the reply does if you don't set it, I think it quite possibly just sends the data out and doesn't try updating anything.

Reply
  • Many ways.

    Easiest one is to specify the data as being in user memory not on the stack, you can then point directly to your data and it will read it right out of the memory.

    Alternately if you specify the characteristic as in user memory and use the RW authorize request, it will send the 22 bytes you give it out as the reply and won't try to copy it anywhere.

    I also don't remember what the 'update' flag in the reply does if you don't set it, I think it quite possibly just sends the data out and doesn't try updating anything.

Children
Related