Android 10 L2CAP connection IOException timeout Wii Balance Board

ぃ、小莉子 提交于 2020-04-11 17:48:46

问题


Background

A long time ago I was tasked with making a android app for the Wii Balance Board, after some screwing around I found that android no longer supported L2CAP. More research lead to understand that it was being re-added in Android 10. With Android 10 out I've been trying to give it a crack now.

Problem

So my simple goal at the moment is to create a connection with the Wii Balance Board.

My approach for connection is:

  • Start discovery

  • Add discovered bluetooth devices to list

  • When you click on a device it then tries to open a socket as such:

    bluetoothSocket = btDevice.createInsecureL2capChannel(port);

  • As mentioned on the WiiBrew site I'm using psm value 0x13 for input and 0x11 for output.

  • I then use bluetoothSocket.connect and proceed to receive a IOException (timeout error)

  • I've also tried using both createL2capChannel and createInsecureL2capChannel with same results

  • I was able to successfully pair to the device using btDevice.createBond() and then using the phones BT address backwards for .setpin() and the Wii Balance Board simply acts as a "dumb" input device. (not sure if pairing is needed/good idea)

The above is a simplified flow of how I'm trying to connect. I've also tried using BalanceBoard.java from Paul Burton's fitscales repo updating all of the old bluetooth code, again I still get the timeout.


回答1:


Have you looked at the bt_stack logs?

Here is mine from trying to open a socket with a wiimote:

04-05 12:25:04.949 E/bt_stack(4895): [ERROR:btif_sock_l2cap.cc(244)] SOCK_LIST: free(id = 4) - NO app_fd!
04-05 12:25:04.949 I/bt_stack(4895): [INFO:btsnoop.cc(323)] clear_l2cap_whitelist: Clearing whitelist from l2cap channel. conn_handle=65535 cid=65:0
04-05 12:25:04.949 E/bt_l2cap(4895): L2CA_FreeLePSM: Invalid PSM=19 value!
04-05 12:25:40.141 I/bt_stack(4895): [INFO:btsnoop.cc(323)] clear_l2cap_whitelist: Clearing whitelist from l2cap channel. conn_handle=1 cid=66:64
04-05 12:25:55.736 I/bt_stack(4895): [INFO:btsnoop.cc(323)] clear_l2cap_whitelist: Clearing whitelist from l2cap channel. conn_handle=2 cid=67:65

I believe this is where the problem lies, Im only a novice so Im not sure what can be done about it. I know the old ways of connecting passed the fd as a parameter to the bluetooth socket constructor but I dont think this is possible anymore



来源:https://stackoverflow.com/questions/59996168/android-10-l2cap-connection-ioexception-timeout-wii-balance-board

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!