Write Data in Other Characteric BLE
Posted: Thu Aug 30, 2018 7:30 pm
Hi everybody,
I'm using the "gatt_server" example (https://github.com/espressif/esp-idf/bl ... tts_demo.c)
and I have some troubles to write and indicate datas in a different characteric that the one I handle.
For example I have 2 services A and B, when I receive a WRITE_EVT in service A, I want to write other datas in a characteristic in the service B.
This is the code part that handle the WRITE_EVT on the service A :
I tried to use this funtion (and tons of others options) :
But it returned me a guru meditation error :
Guru Meditation Error: Core 0 panic'ed (LoadProhibited)
. Exception was unhandled.
Core 0 register dump:
PC : 0x4000c2e0 PS : 0x00060a30 A0 : 0x800f1edd A1 : 0x3ffb3110
A2 : 0x3ffe4920 A3 : 0x00000004 A4 : 0x00004890 A5 : 0x3ffe4920
A6 : 0x00000001 A7 : 0x00000489 A8 : 0x00000000 A9 : 0x3ffb30e0
A10 : 0x3ffe4920 A11 : 0x00004890 A12 : 0x3ffd56f3 A13 : 0x00000000
A14 : 0x00000001 A15 : 0x00000000 SAR : 0x00000008 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000004 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000488
Backtrace: 0x4000c2e0:0x3ffb3110 0x400f1eda:0x3ffb3120 0x400ed0de:0x3ffb3150 0x400eaab5:0x3ffb3180 0x400d57ef:0x3ffb31d0 0x400d5119:0x3ffb3470 0x400f2346:0x3ffb34a0 0x400ed08e:0x3ffb34e0
0x400f1eda: btc_gatts_arg_deep_copy at /root/esp/esp-idf/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c:482
0x400ed0de: btc_transfer_context at /root/esp/esp-idf/components/bt/bluedroid/btc/core/btc_task.c:155
0x400eaab5: esp_ble_gatts_send_indicate at /root/esp/esp-idf/components/bt/bluedroid/api/esp_gatts_api.c:277
0x400d57ef: gatts_profile_a_event_handler at /root/esp/BRIO_RC_ESP32/main/ble.c:573
0x400d5119: gatts_event_handler at /root/esp/BRIO_RC_ESP32/main/ble.c:1020
0x400f2346: btc_gatts_cb_to_app at /root/esp/esp-idf/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c:54
(inlined by) btc_gatts_cb_handler at /root/esp/esp-idf/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c:774
0x400ed08e: btc_task at /root/esp/esp-idf/components/bt/bluedroid/btc/core/btc_task.c:110
Some help would be welcome !
Thanks in advance.
I'm using the "gatt_server" example (https://github.com/espressif/esp-idf/bl ... tts_demo.c)
and I have some troubles to write and indicate datas in a different characteric that the one I handle.
For example I have 2 services A and B, when I receive a WRITE_EVT in service A, I want to write other datas in a characteristic in the service B.
This is the code part that handle the WRITE_EVT on the service A :
Code: Select all
case ESP_GATTS_WRITE_EVT: {
ESP_LOGI(GATTS_TAG, "GATT_WRITE_EVT, conn_id %d, trans_id %d, handle %d", param->write.conn_id, param->write.trans_id, param->write.handle);
if (!param->write.is_prep){
ESP_LOGI(GATTS_TAG, "GATT_WRITE_EVT, value len %d, value :", param->write.len);
esp_log_buffer_hex(GATTS_TAG, param->write.value, param->write.len);
if (gl_profile_tab[PROFILE_A_APP_ID].descr_handle == param->write.handle && param->write.len == 2){
uint16_t descr_value = param->write.value[1]<<8 | param->write.value[0];
if (descr_value == 0x0001){
if (a_property & ESP_GATT_CHAR_PROP_BIT_NOTIFY){
ESP_LOGI(GATTS_TAG, "notify enable");
uint8_t notify_data[15];
for (int i = 0; i < sizeof(notify_data); ++i)
{
notify_data[i] = i%0xff;
}
//the size of notify_data[] need less than MTU size
esp_ble_gatts_send_indicate(gatts_if, param->write.conn_id, gl_profile_tab[PROFILE_A_APP_ID].char_handle,
sizeof(notify_data), notify_data, false);
}
}else if (descr_value == 0x0002){
if (a_property & ESP_GATT_CHAR_PROP_BIT_INDICATE){
ESP_LOGI(GATTS_TAG, "indicate enable");
uint8_t indicate_data[15];
for (int i = 0; i < sizeof(indicate_data); ++i)
{
indicate_data[i] = i%0xff;
}
//the size of indicate_data[] need less than MTU size
esp_ble_gatts_send_indicate(gatts_if, param->write.conn_id, gl_profile_tab[PROFILE_A_APP_ID].char_handle,
sizeof(indicate_data), indicate_data, true);
}
}
else if (descr_value == 0x0000){
ESP_LOGI(GATTS_TAG, "notify/indicate disable ");
}else{
ESP_LOGE(GATTS_TAG, "unknown descr value");
esp_log_buffer_hex(GATTS_TAG, param->write.value, param->write.len);
}
}
}
example_write_event_env(gatts_if, &a_prepare_write_env, param);
esp_ble_gatts_send_indicate(gl_profile_tab[PROFILE_B_APP_ID].gatts_if, 0, gl_profile_tab[PROFILE_B_APP_ID].char_handle, "Test", 4, false);
break;
Code: Select all
esp_ble_gatts_send_indicate(gl_profile_tab[PROFILE_B_APP_ID].gatts_if, 0, gl_profile_tab[PROFILE_B_APP_ID].char_handle, "Test", 4, false);
Guru Meditation Error: Core 0 panic'ed (LoadProhibited)
. Exception was unhandled.
Core 0 register dump:
PC : 0x4000c2e0 PS : 0x00060a30 A0 : 0x800f1edd A1 : 0x3ffb3110
A2 : 0x3ffe4920 A3 : 0x00000004 A4 : 0x00004890 A5 : 0x3ffe4920
A6 : 0x00000001 A7 : 0x00000489 A8 : 0x00000000 A9 : 0x3ffb30e0
A10 : 0x3ffe4920 A11 : 0x00004890 A12 : 0x3ffd56f3 A13 : 0x00000000
A14 : 0x00000001 A15 : 0x00000000 SAR : 0x00000008 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000004 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000488
Backtrace: 0x4000c2e0:0x3ffb3110 0x400f1eda:0x3ffb3120 0x400ed0de:0x3ffb3150 0x400eaab5:0x3ffb3180 0x400d57ef:0x3ffb31d0 0x400d5119:0x3ffb3470 0x400f2346:0x3ffb34a0 0x400ed08e:0x3ffb34e0
0x400f1eda: btc_gatts_arg_deep_copy at /root/esp/esp-idf/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c:482
0x400ed0de: btc_transfer_context at /root/esp/esp-idf/components/bt/bluedroid/btc/core/btc_task.c:155
0x400eaab5: esp_ble_gatts_send_indicate at /root/esp/esp-idf/components/bt/bluedroid/api/esp_gatts_api.c:277
0x400d57ef: gatts_profile_a_event_handler at /root/esp/BRIO_RC_ESP32/main/ble.c:573
0x400d5119: gatts_event_handler at /root/esp/BRIO_RC_ESP32/main/ble.c:1020
0x400f2346: btc_gatts_cb_to_app at /root/esp/esp-idf/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c:54
(inlined by) btc_gatts_cb_handler at /root/esp/esp-idf/components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c:774
0x400ed08e: btc_task at /root/esp/esp-idf/components/bt/bluedroid/btc/core/btc_task.c:110
Some help would be welcome !
Thanks in advance.