Connecting multiple devices to bluetooth in Android

11,471

A UUID is not a unique device identifier; UUIDs are unique identifiers used by the Bluetooth Service Discover Protocol to identify the protocol a Bluetooth device is using. Bluetooth.org has a list of common UUIDs.

Assuming you know or can control the UUID in the guns (it sounds like you can), then you can set up the phone as the Bluetooth server (using the same UUID that the guns use). The guns would then connect as the clients using the same UUID (I know the guns are probably not using Android, but there's some example code there that might be helpful).

Of course, you may need to flip the client/server model around to fit your specific needs. You should be able to make as many of those server and client threads as you need (within the limits of the number of connected devices that your hardware imposes).

Share:
11,471

Related videos on Youtube

Umair
Author by

Umair

SOreadytohelp

Updated on June 21, 2022

Comments

  • Umair
    Umair almost 2 years

    So far what I know that its possible to communicate to multiple devices from your android phone. But my case is that I want to connect two 'similar' devices.

    My understanding is that, I need to use different UUID if I need to connect 2 devices, the bluetooth chat application suggest to hardcoding the UUID.

    Now scenario is that, I m programing for a game, where physical gun will be connected to phone via bluetooth (to track shots etc). Ok here I can ask gun vendor to hard-code a UUID for all guns and phone can connect to 1 gun at a time.. its easy.

    The requirement is that, user may have more then 1 gun! Can somebody tell me how to manage this, if I m hardcoding a single UUID for all guns then I m not sure how to connect multiple guns. And if I m not hardcoding the UUID in gun chip, how I can find the UUID to connect?

  • Prateek
    Prateek almost 10 years
    Why do you think a normal client connection will not work and we have to use a BluetoothServerSocket in such a case
  • Bryan Herbst
    Bryan Herbst almost 10 years
    With Bluetooth, one device needs to be a server and the other devices need to be clients. My suggestion was to use the phone as the server and the guns as clients. Your specific use case may be different.
  • Prateek
    Prateek almost 10 years
    I also have a similar use case but I just want to confirm if making a phone as server provides the functionality to transfer data to and from other bluetooth hardware devices at the same time. And If you can provide a concrete example of this then it will be really helpful.
  • Bryan Herbst
    Bryan Herbst almost 10 years
    The Android Bluetooth documentation has some examples that should give you a good starting point.