Our app needs to programmically pair a bluetooth device with an android phone. This is working fine on all the phones we've tested it on... except the Nexus S.
It was working on this phone until we switched from the legacy (PIN code) pairing, to the newer Secure Simple Pairing (SSP) method.
Here's the log I get when the pairing fails:
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
That's a lot to read so I'll narrow it down (I think). I believe this has something to do with the line
10-31 15:16:49.617: I/BluetoothEventLoop.cpp(110): agent_event_filter: Received method org.bluez.Agent:OutOfBandAvailable
We're thinking the problem is with NFC in the nexus S.... maybe it wants to use NFC to pair?
I've successfully used createInsecureRfcommSocket
(using reflection) to pair... but then I can't receive data from the device on a socket created with listenUsingRfcommWithServiceRecord
(obviously), and we don't want to use listenUsingInsecureRfcommWithServiceRecord
because it requires API level 10, and we'd be cutting out a large number of customers with 2.2/2.3.2 phones.
Any help is appreciated. Thanks!
I could never get this working. It seems as though some android phones refuse to pair using SSP (Nexus S). Our decision was to go back to using the legacy "PIN" pairing method which works reliably (if using the "createRfcommSocket" method accessed via reflection).