1

I am tring to connect my app to server with bluetooth. but i dont know what is this uuid and how should i find it?

class ConnectThread extends Thread {

        private final BluetoothSocket mmSocket;
        private final BluetoothDevice mmDevice;

            // Get a BluetoothSocket to connect with the given BluetoothDevice
            try {
                // MY_UUID is the app's UUID string, also used by the server code
                tmp = device.createRfcommSocketToServiceRecord(MY_UUID);

/// this gives me an error, how shoud i fix it?

Alex Ferents
  • 298
  • 4
  • 10

1 Answers1

1

If you are using BluetoothChat source code, then, locate UUID in file BluetoothChatService.java as shown below:

public class BluetoothChatService {
    .
    .
    // Unique UUID for this application
    private static final UUID MY_UUID_SECURE =
    UUID.fromString("fa87c0d0-afac-11de-8a39-0800200c9a66");
    private static final UUID MY_UUID_INSECURE = 
    UUID.fromString("8ce255c0-200a-11e0-ac64-0800200c9a66");
    .
    .
SunGa
  • 231
  • 3
  • 10
  • How to generate uuid? – appukrb Feb 19 '14 at 06:11
  • 1
    @appubala This discussion and various links therein may help you on UUID [link](http://stackoverflow.com/questions/13964342/android-how-do-bluetooth-uuids-work). In addition this second link though bit outdated but may help the beginners [link](http://wiresareobsolete.com/wordpress/2010/11/android-bluetooth-rfcomm/). – SunGa Feb 19 '14 at 16:45
  • this is common uuid 00001101-0000-1000-8000-00805f9b34fb, what is this fa87c0d0-afac-11de-8a39-0800200c9a66, how you generated this id? – appukrb Feb 20 '14 at 04:25
  • 1
    @appubala BT has 232 [reserved UUID](https://www.bluetooth.org/en-us/specification/assigned-numbers/service-discovery) in 16b form. The UUID, referred by you, is base UUID (128b form, see difference 000011001 vs 00000000). The base UUID with service UUID, forms the complete UUID for each service. Any UUID outside this 232 is a custom uuid. Hence UUID in above code snippet, from BluetoothChat.java, is a custom UUID. New UUID may not be required if your application involves serial port profile (SPP), where UUID mentioned by you is suitable. – SunGa Feb 20 '14 at 15:14
  • i understand the difference between base uuid and service uuid by your above post,is there any way/procedure to obtain/create custom uuid? – appukrb Feb 21 '14 at 04:27
  • 2
    @appubala Sorry, I never used but aware of this [UUID code generator](http://www.itu.int/ITU-T/asn1/uuid.html). In addition google "UUID Generator" to see many websites offering UUID code generation sevice. The [wiki page](http://en.wikipedia.org/wiki/Universally_Unique_Identifier) also provides many useful links. – SunGa Feb 22 '14 at 19:49