esp_ble_gatts_set_attr_value,can not work!

JonathanChenNew
Posts: 11
Joined: Thu Mar 09, 2017 2:52 am

esp_ble_gatts_set_attr_value,can not work!

Postby JonathanChenNew » Tue Mar 14, 2017 8:02 am

Hi
The function(esp_ble_gatts_set_attr_value) can not change attr_value.It returns OK,but when i use " esp_ble_gatts_get_attr_value",i found that the value has no change.And i have set "ESP_GATT_RSP_BY_APP".
My code:

Code: Select all

case ESP_GATTS_WRITE_EVT: {
		ESP_LOGI(UPDATE_GATTS_TAG, "GATT_WRITE_EVT, conn_id %d, trans_id %d, handle %d\n", param->write.conn_id, param->write.trans_id, param->write.handle);
		ESP_LOGI(UPDATE_GATTS_TAG, "GATT_WRITE_EVT, value len %d, value %08x\n", param->write.len, *(uint32_t *)param->write.value);
		LOG_ERROR("write value = %d\n",param->write.value[0]);
		esp_ble_gatts_set_attr_value(param->write.handle,param->write.len,param->write.value);
		esp_ble_gatts_send_response(gatts_if, param->write.conn_id, param->write.trans_id, ESP_GATT_OK, NULL);

		break;
	}
Thanks!

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: esp_ble_gatts_set_attr_value,can not work!

Postby ESP_Angus » Wed Mar 15, 2017 7:46 am

Hi Jonathan,

Does the discussion in this Github issue apply to your code?
https://github.com/espressif/esp-idf/issues/428


Angus

JonathanChenNew
Posts: 11
Joined: Thu Mar 09, 2017 2:52 am

Re: esp_ble_gatts_set_attr_value,can not work!

Postby JonathanChenNew » Tue Mar 21, 2017 5:05 am

ESP_Angus wrote:Hi Jonathan,

Does the discussion in this Github issue apply to your code?
https://github.com/espressif/esp-idf/issues/428


Angus
thank you
but it doesn't work.

jesseb
Posts: 29
Joined: Tue Jan 10, 2017 5:36 pm

Re: esp_ble_gatts_set_attr_value,can not work!

Postby jesseb » Wed Mar 29, 2017 2:48 pm

I haven't gotten the esp_ble_gatts_set_attr_value to work either. I can only change the value by remote writes. As far as I understand the esp_ble_gatts_set_attr_value is meant for when you use the attribute table and the control setting is ESP_GATT_AUTO_RSP. If it was ESP_GATT_RSP_BY_APP then you would simply use esp_ble_gatts_send_response when they read the value and cache whatever value passed when they the controller/client performs a write.

tamhan
Posts: 8
Joined: Tue May 19, 2020 7:22 pm

Re: esp_ble_gatts_set_attr_value,can not work!

Postby tamhan » Wed May 17, 2023 4:55 am

Attention! The handle table is initialized ASYNC, as in, some time after the main stack is inited.

I solved this problem by updating the BLE store only on device connect.

Also, keep in mind that the method returns ESP_OK even if the handle is unitialiyed, in this case it just bins the result.

Who is online

Users browsing this forum: No registered users and 188 guests