[Question]: Purpose of passing in a value to esp_ble_gatts_add_char?
Posted: Tue Jul 18, 2017 12:50 am
There is a BLE function called esp_ble_gatts_add_char() which registers a new characteristic with a previously created BLE service. As I study this API, I find myself puzzled by the existence of a parameter called "char_value".
See the API ref here: http://esp-idf.readthedocs.io/en/latest ... _control_t
This parameter seems to supply a value for the characteristic. Which, in and of itself seems logical ... if we are going to be a BLE server and a peer asks us for the data, we should have it available to return ... but wait ... my understanding of the architecture is that if a peer client asks us for the value of a characteristics then we will receive an ESP_GATTS_READ_EVT and our event handler is then responsible for returning the value. This seems to say I have a big old hole in my understanding. If we (the programmer) are responsible for returning the current characteristic value on a read request, why would we ever need to pass in a value to the attribute registration function?
See the API ref here: http://esp-idf.readthedocs.io/en/latest ... _control_t
This parameter seems to supply a value for the characteristic. Which, in and of itself seems logical ... if we are going to be a BLE server and a peer asks us for the data, we should have it available to return ... but wait ... my understanding of the architecture is that if a peer client asks us for the value of a characteristics then we will receive an ESP_GATTS_READ_EVT and our event handler is then responsible for returning the value. This seems to say I have a big old hole in my understanding. If we (the programmer) are responsible for returning the current characteristic value on a read request, why would we ever need to pass in a value to the attribute registration function?