List and connect to Bluetooth devices

喜欢而已 提交于 2019-12-02 07:28:45
Jens Borrisholt

I've just got a little wiser, ive forund an other SO question telling me that it is not posible.

Search and Connect to Bluetooth device in Windows 8/8.1 Store apps?

So the solution for listing is:

1) Pair your devices

2) List them :

ListBox1.Items.Clear();

    var devices = await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort));

    foreach (var device in devices)
    {
        ListBox1.Items.Add(device);
    }

Have you set the device capabilities yet? You have to define the Id and Function type yourself.

Useful link: How to set device capabilities.

 <m2:DeviceCapability Name="bluetooth.rfcomm">
  <m2:Device Id="any">
    <m2:Function Type="serviceId:00001101-0000-1000-8000-00805F9B34FB"/>
  </m2:Device>
</m2:DeviceCapability>

Furthermore, it is true that you cannot connect unpaired devices. (Windows appears to not support it.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!