Understanding GUID(UUID) in low level Bluetooth programming under Windows. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Understanding GUID(UUID) in low level Bluetooth programming under Windows.

So I dove deep in the world of programming, upto the low level hardwares to make use of the bluetooth socket in Windows. Then I came across the word 'GUID' so many times. According to what I understood from the articles, "The UUID is used for uniquely identifying information. It identifies a particular service provided by a Bluetooth device." Now I am confused about on which side I should provide the GUID ? In client or server? Or do they (server and client) both require to have a GUID address to start up bluetooth communication ? And another question I have in my mind is that , can GUID be any random instead some already defined GUID s on internet ? And are "Service Class Id" and "GUID" same in Windows bluetooth programming ? NB: GUID and UUID , both terms are almost same from the perspective of Bluetooth programming in Windows.

9th Apr 2023, 7:25 AM
[B.S.] BITTU
[B.S.] BITTU - avatar
22 Answers
+ 1
Answer to the last question In Windows Bluetooth programming, the term "Service Class ID" (SCID) is used instead of "GUID" to refer to the same concept. The SCID is a 128-bit value that identifies a Bluetooth service. Therefore, in Windows Bluetooth programming, the terms "SCID" and "GUID" are used interchangeably. I asked my brother about this fact cause he had done this earlier
11th Apr 2023, 4:53 PM
I am offline
I am offline - avatar
+ 1
Snehil Can I use any random UUID for windows bluetooth server advertisement? Or I am bound to use the system UUID?
11th Apr 2023, 5:02 PM
[B.S.] BITTU
[B.S.] BITTU - avatar
+ 1
[B.S.] BITTU well you are not bound to use the system UUID when broadcasting a Bluetooth service in Windows. You can use any uuid that is unique to your application. but its important to ensure that the uuid is truly unique to avoid conflicts with other services.
11th Apr 2023, 5:06 PM
I am offline
I am offline - avatar
+ 1
Snehil Can I use UuidFromString() function to create a UUID from string... will it do? And brother ,this thread is going to be long as I have a lot of questions about bluetooth socket programming under windows so, all I wish is your company and help. I hope you won't mind.
11th Apr 2023, 5:20 PM
[B.S.] BITTU
[B.S.] BITTU - avatar
+ 1
[B.S.] BITTU well you can use that but from this I came to know that you are using c++ to code it that means it's particularly for Windows only I'm ready to have conversations but I'm not that knowledgeable in this field
11th Apr 2023, 5:27 PM
I am offline
I am offline - avatar
+ 1
Yes I am doing it in C++ and particularly targeting windows for now. So I have created a server and advertised it with a random UUID using WSASetService: like this link below https://stackoverflow.com/questions/70475988/how-to-use-wsasetservice-to-advertise-bluetooth-service-using-wsaqueryset-struct On client side I used SOCKADDR_BTH BLTHADDR; BLTHADDR.addressFamily = AF_BTH; BLTHADDR.port = BT_PORT_ANY BLTHADDR.btAddr = [remote addr] BLTHADDR.serviceClassId = [UUID_OF_SERVER] After Having run this code with, connect(socket, (sockaddr*)&BLTHADDR, sizeof(BLTHADDR)), then connect returns 10060 (Timed Out) Can you guess what is possibly going wrong? Both my laptops are paired already.
11th Apr 2023, 5:33 PM
[B.S.] BITTU
[B.S.] BITTU - avatar
+ 1
[B.S.] BITTU Check if there is a firewall or antivirus software that is blocking the connection or check btAddr member of SOCKADDR_BTH is set to the correct Bluetooth address of the server device well I can guess not more than these I'm not that experienced in these so maybe you should ask some experienced people over here cause I read only some parts of this section
11th Apr 2023, 5:35 PM
I am offline
I am offline - avatar
+ 1
It was the client side firewall that was blocking the socket and thanks a lot my friend Snehil You are a life saver
11th Apr 2023, 6:01 PM
[B.S.] BITTU
[B.S.] BITTU - avatar
+ 1
[B.S.] BITTU happy to hear that I'm not noob in this 😂
11th Apr 2023, 6:03 PM
I am offline
I am offline - avatar
+ 1
Snehil Well , I have got another question in mind. I have read somewhere that some portion of GUID defines the type of service I am willing to use and I have seen most of the bluetooth GUIDs to have a identical syntax like: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX Where there are 5 segments separated by dashes. The first segment has 8 hexadecimal digits , next three segments have 4 hexadecimal digits and the last segment has 12 hexadecimal digits. So do these segments denote or signify something about service it provides or it is just a random hexadecimal identifier ?
12th Apr 2023, 3:08 AM
[B.S.] BITTU
[B.S.] BITTU - avatar
+ 1
[B.S.] BITTU it's random and each segment has some specific function/use
12th Apr 2023, 3:26 AM
I am offline
I am offline - avatar
+ 1
Snehil Can you provide any link where the function of each segment is described? I have found this: https://learn.microsoft.com/en-us/windows-hardware/drivers/install/system-defined-device-setup-classes-available-to-vendors But this doesn't describe functionality of each segment separately. well, it also doesn't matter until I get my works done perfectly...
12th Apr 2023, 4:26 AM
[B.S.] BITTU
[B.S.] BITTU - avatar
+ 1
[B.S.] BITTU I don't know much about what each part does so I can't recommend but I think that there might be some information about UUIDs on website: https://www.bluetooth.com
12th Apr 2023, 4:40 AM
I am offline
I am offline - avatar
+ 1
Snehil I am willing to connect my bluetooth earphones with my laptop using winsock. So do you know in which mode are bluetooth earphones set by default ? Server or Client ? And in which mode do they communicate , SOCK_STREAM or SOCK_DGRAM ?
12th Apr 2023, 4:43 AM
[B.S.] BITTU
[B.S.] BITTU - avatar
+ 1
[B.S.] BITTU in general Bluetooth earphones act like client as they initiate a connection to another device generally communication mode depends on the specific protocol and profile that earphones uses
12th Apr 2023, 4:49 AM
I am offline
I am offline - avatar
+ 1
Snehil Do you have any good website for that ?
12th Apr 2023, 4:54 AM
[B.S.] BITTU
[B.S.] BITTU - avatar
+ 1
Snehil Thanks a lot friend for helping me out throughout this tough journey.
12th Apr 2023, 5:02 AM
[B.S.] BITTU
[B.S.] BITTU - avatar
+ 1
[B.S.] BITTU well website related to? if completely about Bluetooth Core: www.bluetooth.com/specificatons
12th Apr 2023, 5:06 AM
I am offline
I am offline - avatar
+ 1
Snehil Website related to how bluetooth earphones actually work? Your link too is a good destination I think
12th Apr 2023, 5:08 AM
[B.S.] BITTU
[B.S.] BITTU - avatar