How can I read attribute property?

User4356
Posts: 35
Joined: Wed Feb 17, 2021 7:52 am

How can I read attribute property?

Postby User4356 » Fri Mar 12, 2021 3:50 pm

Hello.

Is it possible to get attribule property, having The attribute handle?
During the ESP_GATTS_WRITE_EVT event, I have access to the write options and there is an attribute handle field there.

Code: Select all

    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; 
can i use this handle to get the properties of an attribute specified at creation time (ESP_GATT_CHAR_PROP_BIT_READ | ESP_GATT_CHAR_PROP_BIT_WRITE | ESP_GATT_CHAR_PROP_BIT_NOTIFY):

Code: Select all

     
     esp_err_t add_char_ret =  esp_ble_gatts_add_char(gl_profile_tab[PROFILE_A_APP_ID].service_handle,  
                            &gl_profile_tab[PROFILE_A_APP_ID].char_uuid,  ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,  
                            ESP_GATT_CHAR_PROP_BIT_READ | ESP_GATT_CHAR_PROP_BIT_WRITE | ESP_GATT_CHAR_PROP_BIT_NOTIFY,  
                            &gatts_demo_char1_val,  NULL);
                            

ESP_XieWX
Posts: 27
Joined: Fri Jun 22, 2018 7:39 am

Re: How can I read attribute property?

Postby ESP_XieWX » Thu Mar 25, 2021 3:17 pm

BLE services table are defined in the local, so you can save the property when you create the table.

User4356
Posts: 35
Joined: Wed Feb 17, 2021 7:52 am

Re: How can I read attribute property?

Postby User4356 » Tue Apr 20, 2021 3:43 pm

Thank you for reply.
Does the characteristic is the exacly what I wrote in gatts_profile_inst table? Than why exist esp_ble_gatts_set_attr_value and esp_ble_gatts_get_attr_value functions? is there any difference in the fact that I will directly read and write characteristic values (.value) to the server profile table or use the API?

Who is online

Users browsing this forum: Baidu [Spider], cdollar and 131 guests