gpt4 book ai didi

android 6+ 如何连接wii平衡板?

转载 作者:行者123 更新时间:2023-11-29 19:25:52 25 4
gpt4 key购买 nike

我基于 Fitscales code 制作了一个 Android 应用程序,可以很好地连接和读取 Wii 平衡板的输入.在 Android 4.4 (KitKat) 停止对 Wii 的支持之前,我的应用程序在 SDK 15 和 16 上运行得很好。现在重新启用 Wii 支持,从 Android 5.1.1 开始.我还实现了用于获取蓝牙连接权限的新权限方案(包括 ACCESS_COARSE_LOCATION)

我的问题是我无法再读取 Wii 平衡板输入。

我可以发现、创建套接字,当连接到套接字时我收到消息:read failed, socket might closed or timeout, read ret: -1

到目前为止对我有帮助但不再有效的答案:

Create wiimote socket

How to connect

部分代码:

private BluetoothSocket createBluetoothSocket(
int type, int fd, boolean auth, boolean encrypt, String address, int port){
try {
Constructor<BluetoothSocket> constructor = BluetoothSocket.class.getDeclaredConstructor(
int.class, int.class,boolean.class,boolean.class,String.class, int.class);
constructor.setAccessible(true);
BluetoothSocket clientSocket = constructor.newInstance(type,fd,auth,encrypt,address,port);
return clientSocket;
} catch (Exception e) {
Log.v(TAG,"createBluetoothSocket failed: "+errorMsg(e));
return null;
}
}


private connectWii(String MAC) {
try {
// MAC is the MAC address of Wiiboard
int TYPE_L2CAP=3;
sk = createBluetoothSocket(TYPE_L2CAP, -1, false,false, MAC, 0x13);
// this fires read failed, socket might closed or timeout, read ret: -1
sk.connect();
} catch (Exception e) {
Log.v(TAG,"Failed : "+errorMsg(e));
}
}

提前感谢您的帮助。

最佳答案

这个问题的回答值得一看 - https://android.stackexchange.com/a/105285

Android 4.1 及以下版本似乎提供了对 L2CAP 协议(protocol)的访问权限,以连接到已从较新的 Android 版本中删除的蓝牙经典设备(大约 2005 年及更早版本)。

关于android 6+ 如何连接wii平衡板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41451817/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com