Android Find the UUID of a specific bluetooth device

24,868

UUIDs are not tied to particular devices. They identify software services. Some UUIDs for defined profiles are set by BT. The UUIDs used with RFCOMM sockets like your example are arbitrary. You just need both sides to use the same one. In general, devices connect and then use service discovery protocol to find out what services (UUIDs) are supported on the remote device.

Share:
24,868
checai
Author by

checai

Updated on July 05, 2022

Comments

  • checai
    checai almost 2 years

    I'm starting to work on Bluetooth in Android recently. I want to build an application that can read the data recorded by a sensor through bluetooth.

    I have some sample code, but looks like I need another UUID of a different device.It looks like this:

    private static final UUID MY_UUID = UUID
                    .fromString("00001101-0000-1000-8000-00805F9B34FB");
    

    Later on in the code, it uses this UUID to make a connection:

    tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
    

    I have done some research online, like [here][1]. I think I need a different UUID number for the new device I'm working on. How do I get the UUID number?

    On the device, there are two lines of number saying:

    SN: 1201L0023
    BT: 10:00:E8:C5:16:85

    Thanks in advance!

    Jake

  • checai
    checai over 11 years
    I think the "00001101-0000-1000-8000-00805F9B34FB" is the most common UUID.(according to here: developer.android.com/reference/android/bluetooth/…) I don't understand "need both sides to use the same one" in your answer. How do you make sure both the phone(running the application) and sensor(collecting data) have the same UUID? Thanks for you reply
  • TJD
    TJD over 11 years
    That is the one and only UUID for SPP (serial port profile). If your sensor implements SPP, then you use that UUID. But devices could also just use RFCOMM sockets without doing SPP, in which case the UUID could be arbitrary. Your answers should be found in the documentation for your sensor.