我正在开发一个 Android 项目,我想在 Android 设备和 Wii 遥控器/平衡板之间进行连接和通信。目前我正在尝试使用 motej 库 和 bluecove 库 来完成此任务。我知道这两个库可以在 Android 下协同工作以连接设备,因为我设置了一个正确连接的测试应用程序(并且可以发送数据,我可以使远程发出隆隆声并打开或关闭任何 LED)但它在连接建立后不久就意外关闭了。我不确定为什么结局会是这样。我对蓝牙开发非常陌生,所以我认为使用库走这条路线会让我启动并运行,而不必了解有关连接的很多细节。但由于我当前的测试应用程序遇到了一些问题,我开始怀疑我是否应该为这些库操心,或者在 Android 蓝牙 API 下工作以实现设备连接和通信是否更有效。所以我的问题是:
- 是否可以连接并
发送/接收我想要的数据
需要为了获得所有
Wii遥控器的功能
标准Android蓝牙下
API 还是我必须使用
类似bluecove图书馆的东西
我现在有吗?
- 如果可以在没有第 3 方蓝牙库的情况下执行此操作,我是否最好修改 motej 库之类的内容以与 Android 蓝牙 API 配合使用,而不是像现在与 javax.bluetooth 配合使用?或者它是否需要如此多的改变,以至于我可能会放弃它并开始开发我自己的新库?
- 有谁有任何线索可能
为我指明正确的方向
获取它测试应用程序,因为我现在拥有它
固定的?我的日志输出如下,我通过连接正常,但一秒钟后我的应用程序关闭,没有强制关闭对话框或任何东西。
- 有谁知道有一个图书馆
旨在提供对 Wii 遥控器的访问
与蓝牙实际上是
专为与 Android 配合使用而设计
只是java?
INFO/System.out(31264):找到微粒:00191D652A6B
INFO/WiiMoteTest1(31264): 00191D652A6B
WARN/System.err(31264): 14821 [DeviceInquiryThread-0] INFO motej.MoteFinder - found device: TOSHIBA-USER - 00037AB338F7 - 256:12 - 1835008
ERROR/BluetoothEventLoop.cpp(9154): event_filter: Received signal org.bluez.Adapter:DeviceFound from /org/bluez/30823/hci0
DEBUG/BluetoothService(9154): updateDeviceServiceChannelCache(00:03:7A:B3:38:F7)
ERROR/BluetoothEventLoop.cpp(9154): event_filter: Received signal org.bluez.Adapter:DeviceFound from /org/bluez/30823/hci0
DEBUG/BluetoothService(9154): updateDeviceServiceChannelCache(00:03:7A:B3:38:F7)
WARN/System.err(31264): 17470 [DeviceInquiryThread-0] INFO motej.MoteFinder - inquiry completed
DEBUG/dalvikvm(30209): GC_EXPLICIT freed 93 objects / 4464 bytes in 80ms
DEBUG/dalvikvm(31264): Debugger has detached; object registry had 0 entries
WARN/dalvikvm(31264): ReferenceTable overflow (max=512)
WARN/dalvikvm(31264): Last 10 entries in JNI local reference table:
WARN/dalvikvm(31264): 502: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 503: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 504: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 505: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 506: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 507: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 508: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 509: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 510: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 511: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): JNI local reference table summary (512 entries):
WARN/dalvikvm(31264): 512 of Ljava/lang/Class; 164B (1 unique)
WARN/dalvikvm(31264): Memory held directly by tracked refs is 164 bytes
ERROR/dalvikvm(31264): Failed adding to JNI local ref table (has 512 entries)
INFO/dalvikvm(31264): "in:00191D652A6B" prio=5 tid=12 RUNNABLE
INFO/dalvikvm(31264): | group="main" sCount=0 dsCount=0 s=N obj=0x44d59738 self=0x2501b8
INFO/dalvikvm(31264): | sysTid=31283 nice=0 sched=0/0 cgrp=default handle=2425592
INFO/dalvikvm(31264): | schedstat=( 49835206 61798099 541 )
INFO/dalvikvm(31264): at com.intel.bluetooth.BluetoothStackBlueZ.l2Receive(Native Method)
INFO/dalvikvm(31264): at com.intel.bluetooth.BluetoothL2CAPConnection.receive(BluetoothL2CAPConnection.java:117)
INFO/dalvikvm(31264): at motej.IncomingThread.run(IncomingThread.java:260)
ERROR/dalvikvm(31264): VM aborting
I am working on a project on Android where I want to connect and communicate between my Android device and a Wii Remote / Balance Board. Currently I am trying to use the motej library and the bluecove library to accomplish this. I know that these two libraries can work together underneath Android to get a device connected because I have a test app set up that is connecting correctly (and can send data, I can make the remote rumble and set any of the LEDs on or off) but it unexpectedly closes a moment after the connection is made. I am not sure why its ending like this yet. I am very new to bluetooth development so I thought going this route with the libraries would get me up and running without having to understand much of the nitty gritty about the connection. But since I am having some problems with my current test app I am starting to wonder if I should be even bothering with these libraries at all or if it might be mroe effective to work under the Android bluetooth API to get the devices connected and communicating. So my questions are:
- Is it possible to connect and
send/receive the data that I would
need to in order to get all of the
functionality of the wii remote
under the standard Android Bluetooth
API or am I going to have to use
something like the bluecove library
that I have now?
- If it is possible to do this without a 3rd party bluetooth library am I going to be better off modifying something like the motej library to work with the Android Bluetooth API instead of how it does now with javax.bluetooth? Or is it going to require so much change that I might as well just scrap that and start work on my own new library?
- Does anyone have any clue that might
point me in the right direction for
getting it test app as I have it now
fixed? My log output is below, I am making it through the connection fine but a second afterward my app closes without a force close dialog or anything.
- Does anyone know of a library that
aims to give access to a Wii remote
with bluetooth that is actually
built to work with Android instead
of just java?
INFO/System.out(31264): Found mote: 00191D652A6B
INFO/WiiMoteTest1(31264): 00191D652A6B
WARN/System.err(31264): 14821 [DeviceInquiryThread-0] INFO motej.MoteFinder - found device: TOSHIBA-USER - 00037AB338F7 - 256:12 - 1835008
ERROR/BluetoothEventLoop.cpp(9154): event_filter: Received signal org.bluez.Adapter:DeviceFound from /org/bluez/30823/hci0
DEBUG/BluetoothService(9154): updateDeviceServiceChannelCache(00:03:7A:B3:38:F7)
ERROR/BluetoothEventLoop.cpp(9154): event_filter: Received signal org.bluez.Adapter:DeviceFound from /org/bluez/30823/hci0
DEBUG/BluetoothService(9154): updateDeviceServiceChannelCache(00:03:7A:B3:38:F7)
WARN/System.err(31264): 17470 [DeviceInquiryThread-0] INFO motej.MoteFinder - inquiry completed
DEBUG/dalvikvm(30209): GC_EXPLICIT freed 93 objects / 4464 bytes in 80ms
DEBUG/dalvikvm(31264): Debugger has detached; object registry had 0 entries
WARN/dalvikvm(31264): ReferenceTable overflow (max=512)
WARN/dalvikvm(31264): Last 10 entries in JNI local reference table:
WARN/dalvikvm(31264): 502: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 503: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 504: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 505: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 506: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 507: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 508: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 509: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 510: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): 511: 0x44d3a8b8 cls=Ljava/lang/Class; 'Lcom/intel/bluetooth/BluetoothStackBlueZ;' (164 bytes)
WARN/dalvikvm(31264): JNI local reference table summary (512 entries):
WARN/dalvikvm(31264): 512 of Ljava/lang/Class; 164B (1 unique)
WARN/dalvikvm(31264): Memory held directly by tracked refs is 164 bytes
ERROR/dalvikvm(31264): Failed adding to JNI local ref table (has 512 entries)
INFO/dalvikvm(31264): "in:00191D652A6B" prio=5 tid=12 RUNNABLE
INFO/dalvikvm(31264): | group="main" sCount=0 dsCount=0 s=N obj=0x44d59738 self=0x2501b8
INFO/dalvikvm(31264): | sysTid=31283 nice=0 sched=0/0 cgrp=default handle=2425592
INFO/dalvikvm(31264): | schedstat=( 49835206 61798099 541 )
INFO/dalvikvm(31264): at com.intel.bluetooth.BluetoothStackBlueZ.l2Receive(Native Method)
INFO/dalvikvm(31264): at com.intel.bluetooth.BluetoothL2CAPConnection.receive(BluetoothL2CAPConnection.java:117)
INFO/dalvikvm(31264): at motej.IncomingThread.run(IncomingThread.java:260)
ERROR/dalvikvm(31264): VM aborting
发布评论