Connecting and disconnecting to Bluetooth devices has been giving variable results on Windows Phone/Desktop 8.1. I have been using the Windows.Devices.Bluetooth.Rfcomm namespace and I'm trying to connect the following devices with different Bluetooth versions.
LM048 Bluetooth Serial Adapter (Bluetooth 2.0/2.1)
SF51 Mobility Scanner (Bluetooth 1.2)
Unitech MS910 Barcode Scanner (Bluetooth 2.0)
- Windows devices I have tested on are the Nokia Lumia 625/635, Dell Latitude E6500 and a Dell Precision M6400.
Whenever I try to connect to either the LM048 or MS910 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 SF51 scanner that runs on Bluetooth 1.2 works 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)
await RfcommDeviceService.FromIdAsync(this._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. But still in need for a solution.
Is there someone who recognizes these odd results? Am I doing something wrong? (Trying to exclude coding mistakes)
No comments:
Post a Comment