问题描述
连接和断开蓝牙设备一直给在Windows Phone /桌面8.1不同的结果。我一直在使用 Windows.Devices.Bluetooth.Rfcomm
命名空间,我曾尝试几个设备使用不同的蓝牙版本/类连接。
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.
- 版本1.2(1类和2)
- 2.0版本(Class 1和2)
- 2.1版(Class 1和2)
- 在测试了诺基亚Lumia 625和635的Lumia,戴尔Latitude E6500和戴尔precision M6400。
的每当我尝试连接到无论是2.0或2.1的设备有问题。我第一次尝试连接到每个设备的一切会去罚款,连接将打开。当我随后关闭连接,重新连接设备,麻烦开始。的
在重新连接的连接永远不会打开,调试器将抛出一个System.Exception的:
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.
另外,当连接失败在Windows 8.1设备将继续尝试(失败)本身连接到蓝牙设备,即使当您自己的应用程序被终止。有时,在Windows 8.1的设备也将显示蓝牙设备为连接,而该设备直观地表明,它不再连接。重新连接蓝牙设备的唯一方法是取消配对并关机/ Windows设备上重新启动蓝牙功能。
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.
每当我尝试对 DeviceInformation
新呼叫失败的连接它会拒绝返回刚才我试图连接设备后。
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.
奇结果是,1.2的设备正常工作。
Odd result, the 1.2 devices work perfectly.
清单文件:
<m2:DeviceCapability Name="bluetooth.rfcomm">
<m2:Device Id="any">
<m2:Function Type="serviceId:00001101-0000-1000-8000-00805F9B34FB"/>
</m2:Device>
</m2:DeviceCapability>
选择设备:
Guid RfcommChatServiceUuid = Guid.Parse("00001101-0000-1000-8000-00805F9B34FB");
await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.FromUuid(RfcommChatServiceUuid)));
连接:(ID = chatserviceid)
Connecting:(id = chatserviceid)
StreamSocket _socket;
RfcommDeviceService service = await RfcommDeviceService.FromIdAsync(deviceInformation1._id);
await _socket.ConnectAsync(service.ConnectionHostName, service.ConnectionServiceName);
断开:
this._socket.Dispose();
this._socket = null;
我已经研究了MSDN,code样品,演示的,通道9视频的和计算器,没有资源可以告诉我,如果有与问题 Windows.Devices.Bluetooth.Rfcomm
。
有没有人谁认识到了这些奇怪的结果吗?难道我做错了什么?
Is there someone who recognizes these odd results? Am I doing something wrong?
-
观察到类似的问题
<一个href=\"https://social.msdn.microsoft.com/Forums/windowsapps/en-US/c2d2cc7a-b966-42b2-9c04-835b125b404e/disconnecting-bluetooth-devices-with-windowsdevicesbluetoothrfcomm?forum=wpdevelop\">Link MSDN的问题
更新:随着Windows Phone 8.1 GDR2工作是一个可能的解决方案。
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.
推荐答案
我会尝试CoolTerm,看看是否适合您。我有连接与适马DSP芯片内部通过USB连接扬声器类似的问题,因此,如果您无法看到外部设备,可能是设备与您的计算机不兼容。下载CoolTerm并进入选项,并根据串行端口,你应该你的端口切换到所需的连接(蓝牙,USB等),然后根据需要编辑选项,进入到主窗口和命中连接,看看它是否适合你。
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.
这篇关于(DIS)连接的蓝牙设备与Windows.Devices.Bluetooth.Rfcomm(WP8.1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!