QuickLearner
QuickLearner

Reputation: 89

Bluetooth GUID in C#

I use C#.Net (feet32 lib) to build a bluetooth server/client tool. I follow the instruction from https://www.youtube.com/watch?v=Xxnpq6ePQMk, but I met a problem of Guid. After I input the Bluetooth Guid that accessed from my laptop ( Device manager -> double click your bluetooth device to open it's properties -> details -> Class Guid), it still cannot connect. I am not sure the method I obtain GUID is correct, or other problems ? Thanks!

Guid mUUID = new Guid("e0cbf06c-cd8b-4647-bb8a-263b43f0f974");
// Guid mUUID = new Guid("be5ef05c-288d-45d7-b786-eb8e0b0d67cc");
bool serverStarted = false;

public void ServerConnectThread()
{
    serverStarted = true;
    updateUI("server started, wait for client");
    BluetoothListener blueListener = new BluetoothListener(mUUID);
    blueListener.Start();
    BluetoothClient conn = blueListener.AcceptBluetoothClient();
    updateUI("Client has connected");
    Stream mStream = conn.GetStream();
    while (true)
    {
        //handle server connection
        byte[] received = new byte[1024];
        mStream.Read(received, 0, received.Length);
        updateUI("Received:" + Encoding.ASCII.GetString(received));
    }
}

Upvotes: 3

Views: 5575

Answers (2)

Syed Saad
Syed Saad

Reputation: 705

Guid mUUID = BluetoothService.SerialPort;

Try this instead

Upvotes: 0

oziomajnr
oziomajnr

Reputation: 1751

The correct GUID is not class guid but rather its bluetooth service GUID and you would see it from the same list you saw the class GUID . Class GUID and bluetooth service GUID are different.

Upvotes: 3

Related Questions