首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将RN42欺骗为Wiimote

将RN42欺骗为Wiimote
EN

Stack Overflow用户
提问于 2018-02-28 08:02:47
回答 1查看 300关注 0票数 0

RN42 Wireshark Snapshot

Wiimote Wireshark Snapshot

总之,我正在尝试编写一个RN42来欺骗任天堂维莫特。我希望RN42能像Wiimote一样连接Wii。我似乎无法检测到Wii,也无法用我目前掌握的代码连接到它。我使用Raspi连接Wiimote和RN42,以便捕获蓝牙数据包。上面的图片来自wireshark。我注意到由于某种原因,RN42正在进入SDP协议,而不是使用我设置的HID配置文件。我想知道有没有人能帮我修好这个RN42,这样我就可以把它连接到Wii主机上了。

注意:我已经利用RN42和Wiibrew的命令参考来尝试模拟wiimote,但收效甚微。

代码语言:javascript
复制
#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!
}
EN

回答 1

Stack Overflow用户

发布于 2018-07-29 18:32:00

你很可能已经解决或继续前进了,但我现在也在试图弄清楚xbox-360游戏手柄的RN-42,并对HID标志寄存器的工作原理感到有点困惑。

SH命令需要四个十六进制字符,相当于16位。标志寄存器有10位。我不知道怎么把16比特映射到10,但是你的

bluetooth.println("SH,0100"); // Set HID flag to Joystick

命令可能不会将其设置为操纵杆,因为所有示例都表明它需要

bluetooth.println("SH,0240"); // Set HID flag to Joystick

再说一次,我不知道为什么。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49019926

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档