I need to connect android-BluetoothChat to a Raspberry Pi B+, preferably headless. I installed the scripts here to get the Pi to automatically accept pairing requests, and my Android Tablet (a Walmart ONN) says it is paired with my Pi. The correct MAC address appears in the list from BluetoothAdapter.getDefaultAdapter().getBondedDevices()
.
When I run the rfcomm-server.py sample script, it eventually says Accepted connection from ('B4:4B:D6:EE:A2:1C', 1)
.
But the line mmSocket.connect()
in the android-BluetoothChat app fails with the dreaded error java.io.IOException: read failed, socket might closed or timeout, read ret: -1
.
I still don't get a connection when I invoke
the secret method createRfcommSocket()
, which StackOverflow recommends to defeat that error.
So what should I try next?
Another question: What's the UUID for in the interface? Does the server (the Pi) need to match this UUID? I don't see a reason for the android-BluetoothChat program to generate one randomly.
Here's some log, before anyone has to ask for it:
D/BluetoothChatService: connect to: B8:27:EB:8D:DC:E7
D/BluetoothChatService: updateUserInterfaceTitle() 1 -> 2
I/BluetoothChatService: BEGIN mConnectThread SocketType:Insecure
W/BluetoothAdapter: getBluetoothService() called with no BluetoothManagerCallback
V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@d4eebde, this = DecorView@22c41bf[MainActivity]
D/Surface: Surface::disconnect(this=0x7c9bc96000,api=1)
D/Surface: Surface::disconnect(this=0x7c9bc96000,api=1)
W/libEGL: EGLNativeWindowType 0x7c9bc96010 disconnect failed
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = android.view.ViewRootImpl@5720682, this = DecorView@7351cf7[DeviceListActivity]
D/View: [Warning] assignParent to null: this = DecorView@7351cf7[DeviceListActivity]
D/BluetoothSocket: close() this: android.bluetooth.BluetoothSocket@53c843d, channel: -1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@f3d1432, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@9d50583mSocket: android.net.LocalSocket@db37300 impl:android.net.LocalSocketImpl@4722739 fd:java.io.FileDescriptor@ba4417e, mSocketState: INIT
D/BluetoothChatService: updateUserInterfaceTitle() 2 -> 0
D/BluetoothChatService: start
D/BluetoothSocket: close() this: android.bluetooth.BluetoothSocket@53c843d, channel: -1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@f3d1432, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@9d50583mSocket: null, mSocketState: CLOSED
D/BluetoothChatService: updateUserInterfaceTitle() 0 -> 0
D/ViewRootImpl[Toast]: hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
D/Surface: Surface::connect(this=0x7c8b558000,api=1)
D/Surface: Surface::allocateBuffers(this=0x7c8b558000)
D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/Surface: Surface::disconnect(this=0x7c8b558000,api=1)
D/Surface: Surface::disconnect(this=0x7c8b558000,api=1)
W/libEGL: EGLNativeWindowType 0x7c8b558010 disconnect failed
D/View: [Warning] assignParent to null: this = android.widget.LinearLayout{3348471 V.E...... ......ID 0,0-202,49}
I/d.bluetoothcha: Compiler allocated 5MB to compile void android.view.ViewRootImpl.performTraversals()