0

我们的应用程序需要以编程方式将蓝牙设备与安卓手机配对。这在我们测试过的所有手机上都运行良好……除了 Nexus S。

在我们从传统(PIN 码)配对切换到更新的安全简单配对(SSP)方法之前,它一直在这款手机上工作。

这是配对失败时我得到的日志:

10-31 15:16:47.933: D/ShockboxBluetooth(9676): Created socket
10-31 15:16:47.953: E/BluetoothEventLoop.cpp(110): event_filter: Received signal org.bluez.Adapter:DeviceCreated from /org/bluez/254/hci0
10-31 15:16:47.953: E/BluetoothEventLoop.cpp(110): event_filter: Received signal org.bluez.Adapter:PropertyChanged from /org/bluez/254/hci0
10-31 15:16:49.187: E/BluetoothEventLoop.cpp(110): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/254/hci0/dev_00_07_80_4D_B9_00
10-31 15:16:49.566: E/BluetoothEventLoop.cpp(110): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/254/hci0/dev_00_07_80_4D_B9_00
10-31 15:16:49.593: D/BluetoothService(110): updateDeviceServiceChannelCache(00:07:80:4D:B9:00)
10-31 15:16:49.609: D/BluetoothService(110):    uuid(application): 00001101-0000-1000-8000-00805f9b34fb 1
10-31 15:16:49.609: D/BluetoothService(110): Making callback for 00001101-0000-1000-8000-00805f9b34fb with result 1
10-31 15:16:49.617: I/BluetoothEventLoop.cpp(110): agent_event_filter: Received method org.bluez.Agent:OutOfBandAvailable
10-31 15:16:54.156: E/BluetoothEventLoop.cpp(110): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/254/hci0/dev_00_07_80_4D_B9_00
10-31 15:16:54.156: D/BluetoothService(110): 00:07:80:4D:B9:00 bond state 10 -> 12 (0)
10-31 15:16:54.421: I/BluetoothEventLoop.cpp(110): agent_event_filter: Received method org.bluez.Agent:OutOfBandAvailable
10-31 15:16:54.988: E/ShockboxBluetooth(9676): Could not connect to Device
10-31 15:16:54.988: E/ShockboxBluetooth(9676): java.io.IOException: Connection refused
10-31 15:16:54.988: E/ShockboxBluetooth(9676):  at android.bluetooth.BluetoothSocket.connectNative(Native Method)
10-31 15:16:54.988: E/ShockboxBluetooth(9676):  at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:204)
10-31 15:16:54.988: E/ShockboxBluetooth(9676):  at com.Impakt.Shockbox.ShockboxBluetooth$ConnectThread.run(ShockboxBluetooth.java:416)
10-31 15:16:54.992: D/ShockboxBluetooth(9676): Closed socket

有很多要阅读的内容,所以我会缩小范围(我认为)。我相信这与这条线有关

10-31 15:16:49.617: I/BluetoothEventLoop.cpp(110): agent_event_filter: Received method org.bluez.Agent:OutOfBandAvailable

我们认为问题在于 nexus S 中的 NFC ......也许它想使用 NFC 配对?

我已经成功地使用createInsecureRfcommSocket(使用反射)来配对......但是我无法在使用listenUsingRfcommWithServiceRecord(显然)创建的套接字上从设备接收数据,并且我们不想使用listenUsingInsecureRfcommWithServiceRecord,因为它需要 API 级别 10,并且我们会裁掉大量使用 2.2/2.3.2 手机的客户。

任何帮助表示赞赏。谢谢!

4

1 回答 1

0

我永远无法让这个工作。似乎有些安卓手机拒绝使用 SSP (Nexus S) 进行配对。我们的决定是回到使用可靠的传统“PIN”配对方法(如果使用通过反射访问的“createRfcommSocket”方法)。

于 2012-04-25T20:43:23.230 回答