I found the tutorial of client (android) and server (pc) bluetooth tutorial from here.
But my question is about the UUID.
Is that okay if we define it randomly without the proper format? Because I heard UUID is generally for ID for each devices just like IP address used right?
For example like this, instead of the following code:
UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
I define my own UUID
UUID.fromString("myDeviceName009");
Is it okay? I mean is it if i tested on both android device using the above code, they could communicate each other?
No. A UUID has a particular, standardised format.
From the wiki article on the subject:
In its canonical form, a UUID is represented by 32 lowercase hexadecimal digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 alphanumeric characters and four hyphens).
3
A UUID is a standardised representation of a 128-bit number. As noted by AndyBursh, the representation is 32 hexadecimal digits, split into groups and separated by dashes. Nothing else is a proper UUID, it would just be a string.
The point of a UUID is that it’s “universally unique”. If I just pick a string that I like the look of, then there’s no guarantee that somebody else won’t pick the same string.
RFC 4122 defines a number of ways of generating UUIDs so that is is extremely unlikely that two computers will ever generate the same one. This makes it good for device IDs, and almost anything else where you need to attach a unique serial number to something.
Microsoft’s GUID is one implementation of a UUID.
4