Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bluetooth GUID in C#

Tags:

c#

guid

bluetooth

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));
    }
}
like image 634
QuickLearner Avatar asked Jan 28 '26 20:01

QuickLearner


1 Answers

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.

like image 167
oziomajnr Avatar answered Jan 30 '26 10:01

oziomajnr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!