Read long characteristic response limited to 512 bytes

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
3 posts / 0 new
Last post
Myken
Offline
Last seen:1 year 7 months ago
对未来ned:2016-07-13 20:06
Read long characteristic response limited to 512 bytes

Hello,

Got a question regarding the response on a read long characteristic.
It seams that requesting a variable through a read long command on the gatt client side will always result in a data send by the gatt server (dialog) of 512 bytes (in chunks of 20 bytes of-course).

Here some code snippets:

#define SIZE_OF_DATA_BLOCK 4096 /* This compiles fine, but the gatt server will only send the first 512 bytes */

uint8_t DataDumpVar[ SIZE_OF_DATA_BLOCK ];


ble_uuid_from_string( "SOME-UUID-ID", &uuid);
ble_gatts_add_characteristic(&uuid, GATT_PROP_READ, ATT_PERM_READ,
SIZE_OF_DATA_BLOCK, GATTS_FLAG_CHAR_READ_REQ, NULL, &custs->DataDump_val_h);


static void handle_read_req(ble_service_t *svc, const ble_evt_gatts_read_req_t *evt)
{
svc cust_service_t * cust = (cust_service_t *);
if(evt->handle == cust->DataDump_val_h){
ble_gatts_read_cfm(evt->conn_idx, evt->handle, ATT_ERROR_OK, SIZE_OF_DATA_BLOCK, &DataDumpVar[0]);
}
}

--> this code has been simplified to support the question <--

The code above works, no error, no disconnect, just a limit of 512 bytes get send.
EDIT: sorry just checked.SIZE_OF_DATA_BLOCK 4096does compile but does NOT run on the device.SIZE_OF_DATA_BLOCK 512works fine

Now my questions is twofold:
1. where is this 512 bytes limit defined?
2. some thought has gone into setting this limit, question is, why 512? And what are the dragons I'll face if I increase this limit, preferably to 4096, but I guess the bigger the limit the bigger the dragons.

Thanks,
Robert

Device:
MT_dialog
Offline
Last seen:1 month 2 days ago
Staff
对未来ned:2015-06-08 11:34
Hi Myken,

Hi Myken,

It is defined in the BLE stack in ROM since it is dictated by the BLE specification as the maximum length of an attribute which should be 512 bytes in length, please check the specification for more info on this.

Thanks MT_dialog

Myken
Offline
Last seen:1 year 7 months ago
对未来ned:2016-07-13 20:06
Thanks, I was afraid of that.

Thanks, I was afraid of that....