总而言之,我正在尝试对 RN42 进行编程以欺骗任天堂 Wiimote。我想让 RN42 像 Wiimote 一样连接到 Wii。我似乎无法检测到 Wii,或者使用我目前拥有的代码连接到它。我使用 Raspi 连接 Wiimote 和 RN42 以捕获蓝牙数据包。图片来自wireshark。我注意到 RN42 出于某种原因进入了 SDP 协议,并且没有使用我设置的 HID 配置文件。我想知道是否有人可以帮我修复这个 RN42,以便我可以将它连接到 Wii 控制台。
注意:我已经使用了 RN42 和 Wiibrew 的命令参考来尝试模仿 wiimote,但收效甚微。
#include <SoftwareSerial.h>
int bluetoothTx = 3; // TX-O pin of bluetooth mate, Arduino D2
int bluetoothRx = 2; // RX-I pin of bluetooth mate, Arduino D3
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
void setup()
{
Serial.begin(9600); // Begin the serial monitor at 9600bps
bluetooth.begin(115200); // The Bluetooth Mate defaults to 115200bps
bluetooth.print("$"); // Print three times individually
bluetooth.print("$");
bluetooth.print("$"); // Enter command mode
delay(100); // Short delay, wait for the Mate to send back CMD
bluetooth.println("U,9600,N"); // Temporarily Change the baudrate to 9600, no parity
// 115200 can be too fast at times for NewSoftSerial to relay the data reliably
bluetooth.begin(9600); // Start bluetooth serial at 9600
bluetooth.print("$"); // Print three times individually
bluetooth.print("$");
bluetooth.print("$"); // Enter command mode
delay(200); // Short delay
bluetooth.println("SA,0"); // Set authentication to none
delay(200); // Short delay
bluetooth.println("SM,0"); // Set mode to slave
delay(200); // Short delay
bluetooth.println("SH,0100"); // Set HID flag to Joystick
delay(200); // Short delay
bluetooth.println("S~,6"); // Set HID profile
delay(200); // Short delay
bluetooth.println("SC,0000"); // Set HID profile
delay(200); // Short delay
bluetooth.println("SD,2504"); // Set HID profile
delay(200); // Short delay
bluetooth.println("R,1"); // Reboot
delay(400); // Short delay
bluetooth.begin(9600); // Start bluetooth serial at 9600
}
void loop()
{
if(bluetooth.available()) // If the bluetooth sent any characters
{
// Send any characters the bluetooth prints to the serial monitor
Serial.print((char)bluetooth.read());
}
if(Serial.available()) // If stuff was typed in the serial monitor
{
// Send any characters the Serial monitor prints to the bluetooth
bluetooth.print((char)Serial.read());
}
// and loop forever and ever!
}