Hi,
I'm using a Bluetooth RN42 module, connected to an Arduino, as an HID keyboard. I can pair the BT Device to a computer fine. (The BT device is the slave.) I can send HID commands without problem. I can power down the BT Device, and when I power it up again, it automatically reconnects. I can then pair the BT Device to another computer or tablet, and that’s fine too. But when I came back to connect the BT Device to the first computer again, it won’t connect. On the first computer, I have to go into the Bluetooth device manager, remove the BT Device, search and pair again, and then all is ok. I'm pretty sure this is not the correct behaviour, and it's certainly a nuisance. I've read the data sheet several times and tried many different settings, but have not been able to make this work. The data sheet states that the RN42 can store up to 8 paired addresses, so I'm assuming the chip supports the ability to reconnect to any 1 of several already paired devices. My command stream is as follows:
Serial1.print("$$$"); // Command Mode
delay(PostCmdTime);
FlushRxQueue();
Serial1.print("+"); // Echo commands
Serial1.write(CR);
FlushRxQueue();
Serial1.print("S~,6"); // Set HID device
Serial1.write(CR);
FlushRxQueue();
Serial1.print("SM,5"); // Mode = 5, (any) Auto reconnect
Serial1.write(CR);
FlushRxQueue();
Serial1.print("SC,0000"); // Service COD = 00002540 (Periheral, Keyboard)
Serial1.write(CR); // - Service class (upper 2 bytes) = 0000
FlushRxQueue();
Serial1.print("SD,2540"); // - Device Class (2 lower bytes) = 2540
Serial1.write(CR);
FlushRxQueue();
Serial1.print("SA,2"); // Authentication Mode 2 (SSP, "just works" mode)
Serial1.write(CR);
FlushRxQueue();
Serial1.print("SH,0207"); // HID Mode, search last 8 devices and try to connect
Serial1.write(CR);
FlushRxQueue();
Serial1.print("S-,HeadNod"); // Set BT Name,
Serial1.write(CR);
FlushRxQueue();
Serial1.print("R,1"); // Reboot to lock in parameters
Serial1.write(CR);
FlushRxQueue();
delay(PreCmdTime);
Serial1.print("$$$"); // Command Mode
delay(PostCmdTime);
FlushRxQueue();
Serial1.print("+"); // Echo commands
Serial1.write(CR);
FlushRxQueue();
Serial1.print("x"); // Display all settings
Serial1.write(CR);
FlushRxQueue();
Serial1.print("CFI"); // Connect Immediately
Serial1.write(CR);
FlushRxQueue();
Serial1.print("---"); // Exit
Serial1.write(CR);
Any help on how to get this to automatically repair with the original computer, after it has paired with another computer, would be most welcomed.
Thanks, Craig