[Answered]: BLE: Sending a response to a ESP_GATTS_READ_EVT ... data too large
Posted: Sun Jul 02, 2017 2:39 am
I have a BLE Peripheral application which is waiting for characteristic read events. The event I am waiting for is ESP_GATTS_READ_EVT. On receipt of that, I issue an esp_ble_gatts_send_response(). In my unit testing, all was working. However, I had failed to test for longer data sized responses. It seems that if I try and respond with > 22 bytes of response payload, we get the error:
BT: attribute value too long, to be truncated to 22
logged to the console. However we don't get an error indication back from esp_ble_gatts_send_response() ... it returns ESP_OK and it is later in the logs that the error message is returned.
When the error occurs, I seem to see that we very quickly get a second (and then subsequent) ESP_GATTS_READ_EVT received.
When we look at an ESP_GATTS_READ_EVT we see that among its data structure properties is a field called "is_long". This is mysteriously documented in our docs as:
There are many guesses that can be made here ... they could be:
1. We can't have a characteristic > 22 bytes in length
2. We can have a characteristic that is > 22 bytes in length but somehow must "chunk" it into 22 byte parts.
If (2) is correct, then I'd like to have explained (so that I may then document for others) what the procedure should be for working with data lengths. Is there something "magic" about 22? Is this a dynamic setting?
BT: attribute value too long, to be truncated to 22
logged to the console. However we don't get an error indication back from esp_ble_gatts_send_response() ... it returns ESP_OK and it is later in the logs that the error message is returned.
When the error occurs, I seem to see that we very quickly get a second (and then subsequent) ESP_GATTS_READ_EVT received.
When we look at an ESP_GATTS_READ_EVT we see that among its data structure properties is a field called "is_long". This is mysteriously documented in our docs as:
On the very first event to read the characteristic, the passed in value of "is_long" is 0 while on the subsequent events, we find that "is_long" has the value 1.The value is too long or not
There are many guesses that can be made here ... they could be:
1. We can't have a characteristic > 22 bytes in length
2. We can have a characteristic that is > 22 bytes in length but somehow must "chunk" it into 22 byte parts.
If (2) is correct, then I'd like to have explained (so that I may then document for others) what the procedure should be for working with data lengths. Is there something "magic" about 22? Is this a dynamic setting?