HI!
i am having problems with the
esp_ble_gatts_set_attr_value function. I setup my service and characteristic by a gatts table and create it with "esp_ble_gatts_create_attr_tab". The thing is that once created the service and characteristic, i cannot change the craracteristic value with "esp_ble_gatts_set_attr_value". I alredy configure the auto responde. Can anyone of you tell me what i am doing wrong?
here the code:
constants declaration:
Code: Select all
static const uint16_t primary_service_uuid = ESP_GATT_UUID_PRI_SERVICE;
static const uint16_t character_declaration_uuid = ESP_GATT_UUID_CHAR_DECLARE;
static const uint16_t character_client_config_uuid = ESP_GATT_UUID_CHAR_CLIENT_CONFIG;
static const uint8_t char_prop_read_notify = ESP_GATT_CHAR_PROP_BIT_NOTIFY|ESP_GATT_CHAR_PROP_BIT_READ;
static const uint16_t IR_Temperature_svc = 0xD200;
static const uint16_t IR_Temperature_char_uuid = 0xD201;
static const uint8_t char_CCCD_notify[2] = {0x00,0x00};
static const uint16_t IR_CHAR_DECL_HANDLE = 42;
static const uint16_t IR_CHAR_VALUE_HANDLE = 43;
uint8_t IR_Temperature_value[] = {0x00,0x00};
attr tab declaration:
Code: Select all
static const esp_gatts_attr_db_t IR_Temperature_gatt_db[IR_IDX_NB] =
{
// IR Temperature service declaration
[IR_TEMP_IDX_SVC] =
{{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&primary_service_uuid, ESP_GATT_PERM_READ,
sizeof(uint16_t), sizeof(IR_Temperature_svc), (uint8_t *)&IR_Temperature_svc}},
// IR temperature Characteristic declaration
[IR_TEMP_IDX_CHAR] =
{{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_declaration_uuid, ESP_GATT_PERM_READ,
CHAR_DECLARATION_SIZE,CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_read_notify}},
// IR temperature Characteristic value
[IR_TEMP_IDX_VAL] =
{{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&IR_Temperature_char_uuid, ESP_GATT_PERM_READ,
sizeof(IR_Temperature_value), sizeof(IR_Temperature_value), (uint8_t *)IR_Temperature_value}},
// Client Characteristic Configuration Descriptor
[IR_TEMP_IDX_NTF_CFG] =
{{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid,
ESP_GATT_PERM_READ|ESP_GATT_PERM_WRITE,
sizeof(uint16_t),sizeof(char_CCCD_notify), (uint8_t *)char_CCCD_notify}},
};
With this code the nRFconnect App detects correctly the service and characterist with the initial value. When i want to uptate de characteristic value, i call
Code: Select all
//IR_Sensor_read comes from a uart with other data
IR_Temperature_value[0] = IR_Sensor_read[0];
IR_Temperature_value[1] = IR_Sensor_read[1];
esp_err_t rsp;
rsp = esp_ble_gatts_set_attr_value(IR_CHAR_VALUE_HANDLE, sizeof(IR_Temperature_value), (uint8_t *)IR_Temperature_value);
if(rsp==ESP_OK){
ESP_LOGI(GATTS_TAG,"esp_ble_gatts_set_attr_value == ESP_OK\n");
}
else{
ESP_LOGI(GATTS_TAG,"The ERROR: %d\n", rsp);
}
but when i check the nRFconnect app, the value not change.
PD: i use the gatt_tab because the application i am developing has 3 services one for R/W, other for Read and the las for Read and notification.