1

I am developing a client-server bluetooth chat app where multiple clients can connect with the server. If I have multiple servers, I want the client the choose which server it can connect nearby to but I am having problems in knowing which device has the app installed and it is a server. There are multiple bluetooth profiles and I am not sure which one to use it and how. Pre-Storing the MAC id's of the devices with server is one solution but I don't want to do that. Please suggest something. Thanks a lot :)

  • Repeating same [question](http://stackoverflow.com/questions/30434370/discover-devices-which-have-app-installed) for possibly new answers might not be a good practice. Edit your question with more details if necessary to get better answers. – kiranpradeep Jun 16 '15 at 03:48

2 Answers2

0

I assume the intention is to avoid an insecure connection attempt with listenUsingInsecureRfcommWithServiceRecord/createInsecureRfcommSocketToServiceRecord(1).

If you don't mind changing friendly name of the device, just during the device discovery period, you can rename your servers to a pattern of yours with setName(2). On device discovery, you can get the remote device name(3), followed by pattern matching before initiating the connection.

And revert the name, once you are done with discovery.

kiranpradeep
  • 10,859
  • 4
  • 50
  • 82
0

You use a UUID to create the BluetoothServerSocket. This UUID identifies YOUR application and is retrievable by the bluetooth discovery. This UUID is used to connect to your server device as well so you don't need to encode your app's name in the service name.

Check this answer for a detailed description: How do Bluetooth SDP and UUIDs work? (specifically for Android)

Community
  • 1
  • 1
hgross
  • 690
  • 6
  • 15