I'm attempting to adapt the BluetoothChat example that comes with the SDK to 
a single-server, multiple-client configuration. I'm having issues and hope 
someone can help.

I've created two distinct apps, a server and a client, rather than have a 
single app function as both server and client, as in the example. So the 
upon starting the app, the server creates a bluetooth service, which creates 
a new AcceptThread, which listens for incoming connections. I made a couple 
of modifications to the example code so that the AcceptThread continues to 
listen, even after the first connection is made (the example stops listening 
after the one connection is made, because it only needs to establish 
connections between two devices). I created an ArrayList to handle the 
multiple connections. Each time a new connection is attempted from a remote 
device, a new ConnectedThread is created and added to the list.

The first client connects just fine.

When the second client attempts to connect, the connection fails. The log 
output is:

D/BluetoothEventLoop(  140): Device property changed: <device address> 
property: Connected value: true
I/BluetoothService(  140): ACL connected, mAclLinkCount = 2
D/BluetoothEventLoop(  140): Device property changed: <device address> 
property: Connected value: false
I/BluetoothService(  140): ACL disconnected, mAclLinkCount = 1

So it looks like the second connection attempt is successful, but then it is 
immediately disconnected. This looks like it's happening at a low level, 
outside anything the code is handling. This happens with a number of 
different types of test devices, so I don't think it's due to a particular 
firmware or hardware issue. 

Can anyone help with this?

Also, can anyone point to an example of a server->multiple client connection 
example using bluetooth with Android? I came across an Air Hockey example:

http://code.google.com/p/apps-for-android/source/browse/#svn%2Ftrunk%2FBTClickLinkCompete%2Fsrc%2Fnet%2Fclc%2Fbt

But this project is very glitchy on my test devices and the actual game 
won't display properly. Does anyone know if there is an example of 
BluetoothChat extended to handle multiple connections? 

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to