Reputation: 11
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:
One SPP Device works, two have this problem. A not working example: BluePort XP and ASUS USB-BT400
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.
Upvotes: 1
Views: 720