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 4096
does compile but does NOT run on the device.SIZE_OF_DATA_BLOCK 512
works 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
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
Thanks, I was afraid of that....