-
Notifications
You must be signed in to change notification settings - Fork 7.7k
BluetoothSerial SerialToSerialBTM Example #6785
Unanswered
StockBrick
asked this question in
Q&A
-
I am trying to connect the ESP32 as a master to a Bad Elf GPS Pro using the SerialToSerialBTM example in the BluetoothSerial library.
Bluetooth starts on the ESP32 and the Bad Elf shows a pairing request with pin. When the pin is accepted the Bad Elf momentarily shows "paired" but then shows another pairing request which does the same thing.
Serial output from the ESP32 prints a failed to connect message.
Any ideas what is causing this.
Thanks
`void setup()
{
Serial.begin(115200);
SerialBT.begin("ESP32testM",true); //Name of Bluetooth device.
Serial.println("The device started in master mode, make sure remote BT device is on!");
//connect(address) is fast (upto 10 secs max), connect(name) is slow (upto 30 secs max) as it needs
//to resolve name to address first, but it allows to connect to different devices with the same name.
//Set CoreDebugLevel to Info to view devices bluetooth address and device names
//connected = SerialBT.connect(name);
//SJC - Choosing to connect using MAC name rather than familiar name.
connected = SerialBT.connect(address);
if (connected)
{
Serial.println("Connected Succesfully!");
}
else
{
while (!SerialBT.connected(10000))
{
Serial.println("Failed to connect. Make sure remote device is available and in range, then restart app.");
}
}
// disconnect() may take upto 10 secs max
if (SerialBT.disconnect())
{
Serial.println("Disconnected Succesfully!");
}
// this would reconnect to the name(will use address, if resolved) or address used with connect(name/address).
SerialBT.connect();
}
`
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment