BlueTooth Classic Slow reading

Hi to all friends
i made a small app to read via bluetooth the state of 6 switches
I am using an ESP32 D microcontroller to read the switches and to send via Blue Tooth
i am using FreeRTOS

The Esp32 is very fast (ESP32 = 32bit dual-core 160MHz to 240MHz CPU)

i setup the clock in my app inventor app to be 10ms

when my code (after reading the switches ) has a delay of 10ms then my app showing the results very very slow minutes away..

if now increase the delay in my code to 500ms then my app has a delay to read the data just one second
i can live with that but i am curious where is the problem for that lag in reading the data.

i used one app from play store the "Serial Bluetooth Terminal" to connect to my device and it can read the data very fast even when i have 10ms delay in my code, so the code is not the problem i think.. something i am doing wrong in the app inventor setup

Task Code :


void TaskBlueTooth(void *pvParameters) {
  int CheckSafetiesBTh[6];
  for (;;) {
    xQueueReceive(QueueHandle, &CheckSafetiesBTh, portMAX_DELAY);
    if (CheckSafetiesBTh[0] == 0) {
      SerialBT.println("t");
    } else if (CheckSafetiesBTh[0] == 1) {
      SerialBT.println("T");
    } 
    if (CheckSafetiesBTh[1] == 0) {
      SerialBT.println("s");
    } else if (CheckSafetiesBTh[1] == 1) {
      SerialBT.println("S");
    }  
    if (CheckSafetiesBTh[2] == 0) {
      SerialBT.println("d");
    } else if (CheckSafetiesBTh[2] == 1) {
      SerialBT.println("D");
    }    
    if (CheckSafetiesBTh[3] == 0) {
      SerialBT.println("l");
    } else if (CheckSafetiesBTh[3] == 1) {
      SerialBT.println("L");
    }   
    if (CheckSafetiesBTh[4] == 0) {
      SerialBT.println("p");
    } else if (CheckSafetiesBTh[4] == 1) {
      SerialBT.println("P");
    }    
    if (CheckSafetiesBTh[5] == 0) {
      SerialBT.println("e");
    } else if (CheckSafetiesBTh[5] == 1) {
      SerialBT.println("E");
    }
    vTaskDelay(500 / portTICK_PERIOD_MS);
  }
}

MiniPreview.aia (4.4 KB)

Thanks in advance

Try it with 10ms delay. If it doesn't work, try increasing the delay to e.g. 30ms.

MiniPreview4.aia (4.4 KB)

Take into account the minimum time AI2 needs to run the clock timer.