ESP32S3 : Write Characteristic using Bluedroid

ThomasESP32
Posts: 229
Joined: Thu Jul 14, 2022 5:15 am

ESP32S3 : Write Characteristic using Bluedroid

Postby ThomasESP32 » Thu Jan 19, 2023 10:39 am

Good morning,

I am working with ESP32S3-DevKitC-1 and folowwing the examples, I managed to advertise with my device.
Moreover, I managed to create services and characteristics that I can see when I connect to my device using a Smartphone.

Now, I would like to write to my caracteristics and retrieve the informations in the firmware but I do not understand why
there are 2 Write Events : ESP_GATTS_WRITE_EVT and ESP_GATTS_EXEC_WRITE_EVT.

Could you please explain me the difference between these 2 events and more precisely the structures involved :

/**
* @brief ESP_GATTS_WRITE_EVT
*/
struct gatts_write_evt_param {
uint16_t conn_id; /*!< Connection id */
uint32_t trans_id; /*!< Transfer id */
esp_bd_addr_t bda; /*!< The bluetooth device address which been written */
uint16_t handle; /*!< The attribute handle */
uint16_t offset; /*!< Offset of the value, if the value is too long */
bool need_rsp; /*!< The write operation need to do response */
bool is_prep; /*!< This write operation is prepare write */
uint16_t len; /*!< The write attribute value length */
uint8_t *value; /*!< The write attribute value */
} write; /*!< Gatt server callback param of ESP_GATTS_WRITE_EVT */

/**
* @brief ESP_GATTS_EXEC_WRITE_EVT
*/
struct gatts_exec_write_evt_param {
uint16_t conn_id; /*!< Connection id */
uint32_t trans_id; /*!< Transfer id */
esp_bd_addr_t bda; /*!< The bluetooth device address which been written */
#define ESP_GATT_PREP_WRITE_CANCEL 0x00 /*!< Prepare write flag to indicate cancel prepare write */
#define ESP_GATT_PREP_WRITE_EXEC 0x01 /*!< Prepare write flag to indicate execute prepare write */
uint8_t exec_write_flag; /*!< Execute write flag */
} exec_write; /*!< Gatt server callback param of ESP_GATTS_EXEC_WRITE_EVT */

Who is online

Users browsing this forum: Majestic-12 [Bot] and 98 guests