add tag
Anonymous 1317
I am trying to program a uwp app in C#, that must connect to any bluetooth device (not LE) that will be paired with the computer.

I started by copying the Microsoft RFComm Chat sample app, but ran into the problem described [here](https://stackoverflow.com/questions/46877283/uwp-bluetooth-rfcomm-connectasync-problems) (it was too slow, and sometimes dropped the connection for no reason). This SO user solved the problem by using a SerialDevice approach, so I want to implement that.

From [this](https://stackoverflow.com/questions/65143649/unable-to-discover-bluetooth-devices-in-uwp-application-but-works-in-wpf-applica) SO answer, I discovered that Microsoft recommends to use a DeviceWatcher to find all connected Bluetooth devices, so I coded a DeviceWatcher, and it works without a problem. I get a full list of Bluetooth devices as DeviceInformation objects.

However, when I try to use a selected DeviceInformation object to create a SerialDevice, it always fails with "Data is invalid" exception.

```
SerialDevice sd = await SerialDevice.FromIdAsync(myDeviceInfo.Id);
```

gives


> "Die Daten sind unzulässig. (Exception from HRESULT: 0x8007000D)"


("the data are invalid")

The contents of `myDeviceInfo.Id` are 
> Bluetooth#Bluetoothc0:b6:f9:c1:62:62-00:80:25:40:95:7b



I have also tried giving this string in directly as a string parameter, with the same result. The device is already paired with the computer, and was used many times successfully with this Id string and the RfcommService code.

In the manifest, I added the following lines:


```
 <Capabilities>
<DeviceCapability Name="bluetooth.rfcomm">
  <Device Id="any">
    <Function Type="name:serialPort" />
  </Device>
</DeviceCapability>
```

Are the manifest capabilities correct? How can I successfully get a SerialDevice object for the Bluetooth device?

Edit 1: DeviceCapability Name changed to "serialcommunication" but I still get the same exception.

Edit 2: The Bluetooth device with which I am trying to connect exposes COM ports as follows:
![ComPorts.PNG](/image?hash=85ad356401dea87735c4c30a270aa830941a927c7a0338461d40efdac5b735d5)
Top Answer
Anonymous 1317
I figured out what the problem was.  I had not realised that the `Id` field of the `DeviceInformation` class holds  different values, according to the value of the `Kind` field.

So I was getting the `AEP` kind of DeviceInformation for the Bluetooth device, but I needed to be getting the `DeviceInterface` kind instead.

The `Id` field for the `DeviceInterface` kind of DeviceInformation is the correct parameter for `SerialDevice.FromIdAsync(string id)`.

This room is for discussion about this question.

Once logged in you can direct comments to any contributor here.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.