我们的应用程序需要以程序方式将蓝牙设备与Android手机配对。这在我们测试过的所有手机上运行良好......除了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手机切断大量客户。
感谢任何帮助。谢谢!
答案 0 :(得分:0)
我永远无法做到这一点。似乎有些Android手机拒绝使用SSP(Nexus S)进行配对。我们的决定是回到使用可靠工作的传统“PIN”配对方法(如果使用通过反射访问的“createRfcommSocket”方法)。