(Dis)Connecting bluetooth devices with Windows.Devices.Bluetooth.Rfcomm (WP8.1)

Connecting and disconnecting to Bluetooth devices has been giving various results on Windows Phone/Desktop 8.1. I have been using the Windows.Devices.Bluetooth.Rfcomm namespace and I have tried to connect several devices with different Bluetooth versions/classes.

  • Version 1.2 (Class 1 and 2)
  • Version 2.0 (Class 1 and 2)
  • Version 2.1 (Class 1 and 2)
  • Tested on Nokia Lumia 625 and Lumia 635, Dell Latitude E6500 and a Dell Precision M6400.

Whenever I try to connect to either of the 2.0 or 2.1 devices there are issues. The first time I try to connect to each of the devices everything will go fine and the connection will open. When I subsequently close the connection and re-connect the device, the trouble starts. During the re-connect the connection will never open and the debugger will throw a System.Exception :

> Message: No further data is available.

Also, when the connection fails the Windows 8.1 devices will keep trying to (unsuccessfully) connect to the Bluetooth Devices by themselves, even when my own application is terminated. Sometimes the Windows 8.1 device will also show the Bluetooth device as connected, while the device visually shows that it's not connected anymore. The only way to reconnect the Bluetooth device is to unpair it and shutdown/restart Bluetooth on the Windows device.

Whenever I try to make a new call to DeviceInformation after a failed connect it will refuse to return the device that I earlier tried to connect.

> Message: The service cannot be found in the specified name space.

Odd result, the 1.2 devices work perfectly.

Manifest File:

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

Selecting Device:

Guid RfcommChatServiceUuid = Guid.Parse("00001101-0000-1000-8000-00805F9B34FB");
await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.FromUuid(RfcommChatServiceUuid)));

Connecting:(id = chatserviceid)

StreamSocket _socket;
RfcommDeviceService service = await RfcommDeviceService.FromIdAsync(deviceInformation1._id);
await _socket.ConnectAsync(service.ConnectionHostName, service.ConnectionServiceName);

Disconnecting:

this._socket.Dispose();
this._socket = null;

I've researched the MSDN, code samples, demo's, channel-9 video's and StackOverflow, no resource can tell me if there are issues with Windows.Devices.Bluetooth.Rfcomm.

Is there someone who recognizes these odd results? Am I doing something wrong?

UPDATE: Working with Windows Phone 8.1 GDR2 is a possible solution.

NOTE: For myself and several other people this update still gives the same issues.

4697 次浏览

I would try CoolTerm and see if that works for you. I was having a similar issue connecting a speaker with a Sigma DSP chip inside via USB connection, so if you are having trouble seeing external devices it may be that the device is incompatible with your computer. Download CoolTerm and go to options and under Serial Port you should change your Port to the desired connection (bluetooth, usb, etc.) Then edit the options as necessary and go to the main window and hit connect and see if it works for you.