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?
[Question]: Purpose of passing in a value to esp_ble_gatts_add_char?
[Question]: Purpose of passing in a value to esp_ble_gatts_add_char?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: [Question]: Purpose of passing in a value to esp_ble_gatts_add_char?
if auto_rsp set to ESP_GATT_RSP_BY_APP, means the response of Write/Read operation will by replied by application. if auto_rsp set to ESP_GATT_AUTO_RSP, means the response of Write/Read operation will be replied by GATT stack automatically.
Re: [Question]: Purpose of passing in a value to esp_ble_gatts_add_char?
Thank you kind sir. That is a perfect response and a delightful new understanding on my part that there is even more function in ESP-IDF stack that I had ever assumed. Wonderful.
This now begs a follow on question ... if I set auto_rsp to ESP_GATT_RSP_BY_APP then does that mean that I can supply a null pointer to a call to esp_ble_gatts_add_char() for the "char_value" parameter? My gut would assume "yes" since if we are declaring that we are going to handle requests for characteristics values in application logic, then there should be no need to tell the environment about any potential values. However, I'm wrong more than I'm right so I like to check.
This now begs a follow on question ... if I set auto_rsp to ESP_GATT_RSP_BY_APP then does that mean that I can supply a null pointer to a call to esp_ble_gatts_add_char() for the "char_value" parameter? My gut would assume "yes" since if we are declaring that we are going to handle requests for characteristics values in application logic, then there should be no need to tell the environment about any potential values. However, I'm wrong more than I'm right so I like to check.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Who is online
Users browsing this forum: Bing [Bot], chudofthecosmos, egionet and 88 guests