#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); /* Inicializamos la comunicación por puerto serial a 115200 */
SerialBT.begin("BluESP32"); /*Nombre del dispositivo Bluetooth */
delay(1000); /*Esperemos un segundo antes de continuar */
Serial.println("El dispositivo de inicio, ahora puedes emparejarlo con otro dispositivo");
}
void loop() {
if(Serial.available()){
/* Preguntamos si recibimos datos a través del puerto serial */
SerialBT.write(Serial.read()); /* Enviamos por Bluetooth lo que recibimos en el monitor serial */
}
if(SerialBT.available()){
/*Preguntamos si recibimos datos a través del Bluetooth */
Serial.write(SerialBT.read()); /* Enviamos por Bluetooth lo que recibimos por Bluetooth */
}
delay(50);
}