【发布时间】:2019-12-21 22:20:21
【问题描述】:
我想创建双向蓝牙 Rfcomm 连接。服务器端在 UWP 中实现。使用 InTheHand.Devices.Bluetooth (NuGet v4.0.1803.22-preview) 我找不到将 SDP 记录附加到服务提供商的方法。这会导致在尝试宣传服务时出错。
我想可以将“InTheHand”服务提供商转换为 Windows.Devices.Bluetooth.Rfcomm 种类,但如果可能的话,我更喜欢 InTheHand 库中的解决方案。我错过了什么吗?
private async void InitializeService(){
var localRfcommServiceID = RfcommServiceId.FromUuid(uuid);
var localRfcommService = await RfcommServiceProvider.CreateAsync(localRfcommServiceID);
//This is where I would expect to add SDP records to the service provider
localRfcommService.StartAdvertising();
localRfcommService.ConnectionReceived += LocalRfcommService_ConnectionReceived;
}
我尝试开始投放广告时遇到异常。 (对不起德语错误消息)
Exception thrown: 'System.IO.FileNotFoundException' in InTheHand.Devices.Bluetooth.dll
WinRT information: Der StreamSocketListener muss gebunden werden, bevor Sie mit der Ankündigung beginnen können.
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.CoreLib.ni.dll
WinRT information: Der StreamSocketListener muss gebunden werden, bevor Sie mit der Ankündigung beginnen können.
翻译:StreamSocketListener 需要在广播开始之前绑定。
【问题讨论】:
-
嗨,您是否按照错误消息的指示添加了
StreamSocketListener? -
到目前为止,我已经将提供程序转换为 Windows 种类并将其绑定到 StreamSocketLiestener,因为我在 InTheHand 库中找不到明显的绑定方法。似乎正在工作;仍在尝试在客户端发现它。
标签: c# uwp bluetooth rfcomm 32feet