蓝牙 – Windows phone 8.1 streamsocket.connectAsync生成“没
发布时间:2020-12-14 02:21:10 所属栏目:Windows 来源:网络整理
导读:我正在开发必须在蓝牙打印机上打印的 Windows Phone 8.1商店应用程序(XAML). 使用前两种方法成功找到该设备: PeerFinder.AllowBluetooth = True PeerFinder.Role = PeerRole.Client PeerFinder.AlternateIdentities.Item("Bluetooth:SDP") = "{00001101-000
我正在开发必须在蓝牙打印机上打印的
Windows Phone 8.1商店应用程序(XAML).
使用前两种方法成功找到该设备: PeerFinder.AllowBluetooth = True PeerFinder.Role = PeerRole.Client PeerFinder.AlternateIdentities.Item("Bluetooth:SDP") = "{00001101-0000-1000-8000-00805F9B34FB}" 'PeerFinder.AlternateIdentities.Item("Bluetooth:Paired") = "" Dim devs = Await PeerFinder.FindAllPeersAsync() Dim dev As PeerInformation = devs(0) Dim btdevs = Await DeviceInformation.FindAllAsync(BluetoothDevice.GetDeviceSelector()) Dim btdv = btdevs(0) 并没有找到: Dim dfdevs1 = Await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort)) ' same result with Await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.FromUuid(New Guid("00001101-0000-1000-8000-00805F9B34FB"))) 不幸的是,只有最后一个方法会给我“streamServiceName”才能在StreamSocket.ConnectAsync中使用 我尝试过StreamSocket.ConnectAsync的不同组合: dim _soc = New StreamSocket() Await _soc.ConnectAsync(dev.HostName,"1") “没有更多数据可用.(HRESULT异常:0x80070103)” 同样的 dim _soc = New StreamSocket() Await _soc.ConnectAsync(dev.HostName,"{00001101-0000-1000-8000-00805F9B34FB}" 正如你可以想象的那样 dim _soc = New StreamSocket() Await _soc.ConnectAsync(btdv.HostName,"{00001101-0000-1000-8000-00805F9B34FB}" 经过几天敲打我的头脑后,我真的没有想法.最让我烦恼的是,第一个代码组合适用于Windows Phone 8.0 是的,在AppManifest中设置了一切: <DeviceCapability Name="proximity" /> <m2:DeviceCapability Name="bluetooth.rfcomm"> <m2:Device Id="any"> <!--<m2:Function Type="name:serialPort" />--> <m2:Function Type="serviceId:00001101-0000-1000-8000-00805F9B34FB" /> </m2:Device> </m2:DeviceCapability> 任何想法将受到高度赞赏. 解决方法
在我们发言时,我也在研究这个问题,并取得了很好的进展.对我来说,问题出现在我从WP8升级到WP8.1(silverlight)之后.
确保您的appxmanifest具有以下权限集: <m2:DeviceCapability Name="bluetooth.rfcomm"> <m2:Device Id="any"> <m2:Function Type="serviceId:00001101-0000-1000-8000-00805f9b34fb" /> <m2:Function Type="name:serialPort" /> </m2:Device> </m2:DeviceCapability> 下面是我的示例代码,似乎允许连接(至少,在我的测试中!) PeerFinder.AlternateIdentities["Bluetooth:SDP"] = "{00001101-0000-1000-8000-00805f9b34fb}"; //find the device from the device list we are trying to connect to var selector = RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort); var dev = await DeviceInformation.FindAllAsync(selector,null); var devA = dev.Where(f => f.Name.Equals(_item.Device.DisplayName)).FirstOrDefault(); //get the service RfcommDeviceService service = await RfcommDeviceService.FromIdAsync(devA.Id); //create the connection await Common.Instance.Socket.ConnectAsync(service.ConnectionHostName,service.ConnectionServiceName); MetaData.Instance.BlueBoxRef = _item.Device.DisplayName.Substring(8); NavigationService.Navigate(new Uri("/OpenDevice.xaml",UriKind.RelativeOrAbsolute)); 我仍然需要检查这是否适用于其他设备,但请告诉我你是如何进行的! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 如何遍历Windows批处理文件中的文件夹树/子树?
- windows-7 – 更改Windows(7)的方法通过脚本监视设置
- 20164301 Exp2 后门原理与实践
- windows – Apache配置:“没有可用的侦听套接字”
- windows-xp – 绕过RDP客户端警告
- windows-server-2008 – 重启域控制器的步骤?
- Microsoft Edge浏览器不支持收藏夹中的javascript bookmark
- ms-access – 当更新Microsoft Access数据库中的特定表和字
- .net – 在Windows 10上构建Windows Universal App时出现问
- wix – 错误4:选择`消息`FROM`错误`WHERE`错误`= 1707(也是