1

I am developing an application which makes Bluetooth (RFComm, SPP) connections with a device. My Android App works like a charm but with UWP I have big problems getting the connection done using:

socket.ConnectAsync(service.ConnectionHostName, service.ConnectionServiceName);

When the device is connected everything works. Sometimes the ConnectAsync takes a long time (1 minute) or finally it doesnt work.

It seems like when I start the App the first connection works and connects within a vew seconds but all following connections seem to be very unstable.

I tried different USB Dongles, but with same results. I am now on Win 10 Pro 64 1709.

I also tried the UWP RFComm Chat sample app. Same problems there.

Does somebody have similar problems? Any ideas?

Thanks, Joachim

A few updates: I testet a few other Dongles and SPP Devices. My results:

  1. One SPP Device works, two have this problem. A not working example: BluePort XP and ASUS USB-BT400

  2. Using Virtual COM Ports over Win32 API or .net SerialPort works on all devices!

Conclusion: Hardware works. The problem is on UWP using socket.ConnectAsync! Is this a Win10 UWP Bug??!!

Second update:

I found out that if I use Devices from: DeviceInformationCollection collection = await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort));

and connect using rfcomm: var services = await _device.GetRfcommServicesForIdAsync(RfcommServiceId.SerialPort, BluetoothCacheMode.Uncached); var op = _socket.ConnectAsync(_service.ConnectionHostName, _service.ConnectionServiceName);

then I have this problems with connection times - manly after the first connect/disconnect phase

BUT: When I use the virtual com ports created from SPP Dongles

DeviceInformationCollection collection = await DeviceInformation.FindAllAsync("System.Devices.InterfaceClassGuid:=\"{86E0D1E0-8089-11D0-9CE4-08003E301F73}\" AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True");

and create a SerialDevice using: var serialDevice = await SerialDevice.FromIdAsync(info.Id);

which automatically connects the bluetooth target while this serialDevice is created, then everything works perfect.

jstuemp
  • 11
  • 2
  • I test the Bluetooth RFCOMM chat sample that I can not reproduce your issue. The `await chatSocket.ConnectAsync(chatService.ConnectionHostName, chatService.ConnectionServiceName);` work well. Could you please tell us your steps to reproduce the issue? – Jayden Oct 24 '17 at 06:49
  • Hi Jayden, please see my second update of the post. To reproduce with sample app: Replace this: var rfcommServices = await bluetoothDevice.GetRfcommServicesForIdAsync( RfcommServiceId.FromUuid(Constants.RfcommChatServiceUuid), BluetoothCacheMode.Uncached); with: var rfcommServices = await bluetoothDevice.GetRfcommServicesForIdAsync( RfcommServiceId.SerialPort, BluetoothCacheMode.Uncached); and connect to a SPP Bluetooth device – jstuemp Oct 24 '17 at 13:49

0 Answers0