I wrote a simple program in c++ (using the Arduino ide) that opens a Serial Bluetooth connection.
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
BluetoothSerial SerialBT;
void setup() {
Serial.begin(115200);
SerialBT.begin("ESP32test"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
}
void loop() {
if (Serial.available()) {
SerialBT.write(Serial.read());
}
if (SerialBT.available()) {
Serial.write(SerialBT.read());
}
}
the program runs, but when I am trying to connect to ESP32 with my phone it connects successfully but disconnects after a few seconds.
And when I am trying to connect to it via Bluetooth Terminal Application (https://play.google.com/store/apps/details?id=de.kai_morich.serial_bluetooth_terminal&hl=en) the connection won't even start.
I tested the program with multiple ESP32 devices from different types (NODEMCU, WROOM) but all of them had the same problem.
In my case I have to keep channel "alive" sending some character and avoid disconnect