A difference between Service GUID and a server name and a service class in Bluetooth

427 views Asked by At

I've been studing the bluetooth echo server example from windows wdf samples. I want to understand the l2cap bt driver implementation, but I'm still a bit confused.

Below I listed the code from the example.

Here we have a GUID and a name of a service published by the bt server dev. A client has to know that information if it wants to connect to the server.

    //
    // Service GUID and name for the service published by our bth server device
    //
    
    /* c07508f2-b970-43ca-b5dd-cc4f2391bef4 */
    DEFINE_GUID(BTHECHOSAMPLE_SVC_GUID, 0xc07508f2, 0xb970, 0x43ca, 0xb5, 0xdd, 0xcc, 0x4f, 0x23, 0x91, 0xbe, 0xf4);
    
    extern __declspec(selectany) const PWSTR BthEchoSampleSvcName =L"BthEchoSampleSrv";
    
    //
    // Device interface exposed by our bth client device
    //
    
    /* fc71b33d-d528-4763-a86c-78777c7bcd7b */
    DEFINE_GUID(BTHECHOSAMPLE_DEVICE_INTERFACE, 0xfc71b33d, 0xd528, 0x4763, 0xa8, 0x6c, 0x78, 0x77, 0x7c, 0x7b, 0xcd, 0x7b);

Here is how the client can connect to the server:

DWORD err = GetDevicePath((LPGUID)&BTHECHOSAMPLE_DEVICE_INTERFACE, &devicePath);

if (ERROR_SUCCESS != err) {
    printf("Failed to find the BTHECHO device\n");
    exit(1);
}

hDevice = CreateFile(devicePath,
                     GENERIC_READ|GENERIC_WRITE,
                     FILE_SHARE_READ | FILE_SHARE_WRITE,
                     NULL,
                     OPEN_EXISTING,
                     0,
                     NULL );

My question is: what if I have a mobile phone or a tablet and can choose it from my bt list device using WSALookupServiceXXXX. How can I still use or connect to the l2cap driver? How can I get the GUID of an external server device if I'm a client? and the other way around how does the client get to know the GUID server of the server? the GUID and a service class ID (bt profiles) are two different things, aren't they?

Best,

0

There are 0 answers