Help on BLE Notify
Posted: Mon Jan 30, 2017 10:30 am
Hello,
i'm working on "gatt_server" example using ESP32 as BLE server and Android app "BLEscanner" as BLE client. I have been able to make the basic code work so i can discovery and connect. I'm making experiments to improve my ESP-IDF knowledge (i'm using the esp-idf 2.0 RC) adding some features to the example but i'm having hard time with notifications. Let me explain with code:
I started declaring a variable:
I use this variable as a check for the code for reading operation i use, the following one:
With this when i click on "READ" on a characteristic on the app i read the value 0xEE.
About the write operation i tried write this code:
With this code i (TRY) to use the "write.handle" to filter the request. If i write the characteristic the program run the first if and the following READ reads the new "experiment" value. But if i click on NOTIFY experiment value doesn't change to "0xBB".
What i'm doing wrong? Any suggestion would be appreciated!
Regards,
Frax
i'm working on "gatt_server" example using ESP32 as BLE server and Android app "BLEscanner" as BLE client. I have been able to make the basic code work so i can discovery and connect. I'm making experiments to improve my ESP-IDF knowledge (i'm using the esp-idf 2.0 RC) adding some features to the example but i'm having hard time with notifications. Let me explain with code:
I started declaring a variable:
Code: Select all
uint8_t experiment = 0xEE;
Code: Select all
case ESP_GATTS_READ_EVT: {
esp_gatt_rsp_t rsp;
memset(&rsp, 0, sizeof(esp_gatt_rsp_t));
rsp.attr_value.handle = param->read.handle;
rsp.attr_value.len = 1;
rsp.attr_value.value[0] = experiment;
esp_ble_gatts_send_response(gatts_if, param->read.conn_id,
param->read.trans_id, ESP_GATT_OK, &rsp);
break;
About the write operation i tried write this code:
Code: Select all
case ESP_GATTS_WRITE_EVT: {
if (param->write.handle== gl_profile_tab[0].char_handle) { //[0] because i'm using profile A
experiment = (uint8_t)*param->write.value;
} else if (param->write.handle== gl_profile_tab[0].descr_handle) {
esp_ble_gatts_set_attr_value(gl_profile_tab[0].descr_handle, param->write.len,(uint8_t*) param->write.value);
experiment=0xBB;
}
esp_ble_gatts_send_response(gatts_if, param->write.conn_id,param->write.trans_id, ESP_GATT_OK, NULL);
break;
What i'm doing wrong? Any suggestion would be appreciated!
Regards,
Frax