I want to start BLE server with the notifications on ESP32. I was run a "gatts_demo" example in Visual Studio 2022. I make notification sends with RTOS function:
- void V_notif_task(void *p)
- {
- uint8_t notify_data[32];
- memcpy(notify_data, "notify sended", 13);
- while (1)
- {
- if (ne == true)
- {
- if (gatts_if_for_indicate == ESP_GATT_IF_NONE)
- {
- printf("cannot indicate because gatts_if_for_indicate is NONE\n");
- }
- else
- {
- uint16_t attr_handle = 0x002a;
- //the size of notify_data[] need less than MTU size
- esp_ble_gatts_send_indicate(gatts_if_for_indicate, 0, attr_handle, 13, notify_data, false);
- }
- }
- vTaskDelay(1000);
- }
- }
- 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);
- ne = true;
- }
- }
- xTaskCreate(v_test_task, "test_task", configMINIMAL_STACK_SIZE, NULL, 8, NULL);
Code: Select all
***ERROR*** A stack overflow in task test_task has been detected.