Hi, I bought Seeed bluetooth shield 2.0, add it on Leonardo, and successfully made it connect to my PC with Windows 10 installed.
My PC finds the bluetooth module well and I can get data from Leonardo using serial port. Everything is fine.
Here is my question - when I turn off Leonardo and turn it on again, serial communication via SPP is not possible.
I have to manually remove the corresponding BT device in BT device management console of Windows 10 and reconnect the device. In other words, I have to pair the device to PC every time it is powered on. This behavior is not convenient and I want to know how to resolve this issue. As far as I know, most commercial BT devices do not suffer from this issue.
This problem does not happen when BT device (BT shield + Leonardo) is turned on and I reboot my PC.
The code below is what I used to initialize BT shield.
blueToothSerial.begin(9600); blueToothSerial.print("AT"); delay(800); blueToothSerial.print("AT+DEFAULT"); // Restore all setup value to factory setup delay(4000); blueToothSerial.print("AT+NAMESeeedBTSlave"); // set the bluetooth name as "SeeedBTSlave" ,the length of bluetooth name must less than 12 characters. delay(800); blueToothSerial.print("AT+PIN0000"); // set the pair code to connect delay(800); blueToothSerial.print("AT+AUTH1"); delay(800);
After this “factory initialization” I don’t use the above code in my firmware since BT shield remember these settings.
After hours of googling, I test the following code since it seems to make BT shield to auto connect to the last connected device when powered on. But not difference.
Any insight/tips would be greatly appreciated.