Note that there are some explanatory texts on larger screens.

plurals
  1. POAre connected BluetoothSocket RFCOMM channels unique regardless of UUID?
    primarykey
    data
    text
    <p>Basic Question: If I open multiple Bluetooth connections in Android 2.2+, does the UUID matter in ensuring uniqueness of the RFCOMM channel used?</p> <p>Background: I want to create an Android application which will reside on multiple (3+) different Android phones (minimum Android version 2.2). Each instance of the application will communicate with each other via Bluetooth. Therefore each application will have multiple bluetooth connections open simultaneously to talk to all participating applications.</p> <p>I know this is (at least) possible because I extended the BluetoothChat sample application to support N clients all chatting together in a chatroom-type manner. So I have the ability to hold open multiple Bluetooth connections simultaneously.</p> <p>My concern is with the following statement in the android documentation: "Unlike TCP/IP, RFCOMM only allows one connected client per channel at a time, so in most cases it makes sense to call close() on the BluetoothServerSocket immediately after accepting a connected socket." (http://developer.android.com/guide/topics/wireless/bluetooth.html)</p> <p>Now, the fact that my implementation of a chatroom-style BluetoothChat application tells me that my approach to opening simultaneous connections results in connections on different RFCOMM channels (otherwise I would get connection failures or crosstalk). However, I'm not sure what PART of my approach results in the different RFCOMM channels, and that's what this question is about.</p> <p>There are 2 parts to my approach to opening multiple Bluetooth connections: 1. Instead of using the same BluetoothServerSocket object to accept multiple connections via calling accept() over and over, I create a thread that calls listenUsingRfcommWithServiceRecord(String, UUID) for every connection I want to accept. 2. Instead of using the same UUID for each connection, I have a set of 7 UUIDs that I manage manually such that each accept() is sitting on a BluetoothServerSocket created with a different UUID.</p> <p>Now, my understanding from the documentation is that listenUsingRfcommWithServiceRecord(String, UUID) adds an entry to the SDP database for listening. Clearly, the fact that I create a different SDP database entry for each accepted connection is at least part of the reason why different RFCOMM connections are used for each connection. But does the UUID have any impact here? If I were to call the method 7 times on 7 different threads all using the same UUID, would it still work? Or does different UUIDs cause different RFCOMM channels to be used? </p> <p>The issue here obviously is the fact if I have to manage 7 different UUIDS for my application, ensuring proper synchronization of available connection UUIDS as connections are opened and closed can be a huge hassle. If anyone can either confirm or deny that UUIDs have an impact upon RFCOMM channel selection when listenUsingRfcommWithServiceRecord(String, UUID) is called, it would be enormously helpful.</p> <p>(Not discussed-the impact of UUID on the connection side, createRfcommSocketToServiceRecord(UUID); my assumption is that if it holds for incoming it probably holds for outgoing.)</p> <p>Thanks to anyone who can help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload