The*_*Dog 5 c# wifi wifi-direct uwp
我正在使用UWP API启动Wi-Fi Direct接入点服务。它开始确定。我正在使用事件WiFiDirectConnectionListener
监视是否已连接到访问点的设备ConnectionRequested
。
var connectionRequest = args.GetConnectionRequest();
var deviceInformation = connectionRequest.DeviceInformation;
// FromIdAsync needs to be called from the UI thread (in MS example).
var isConnected = RunOnUIThreadAsync(() =>
{
try
{
var device = WiFiDirectDevice.FromIdAsync(deviceInformation.Id).AsTask().Result;
if (device != null)
{
device.ConnectionStatusChanged -= OnDeviceConnectionStatusChanged;
device.ConnectionStatusChanged += OnDeviceConnectionStatusChanged;
return true;
}
return false;
}
catch (Exception e)
{
// This throws an Exception from HRESULT: 0x800705B4.
return false;
}
}).Result;
Run Code Online (Sandbox Code Playgroud)
在那可以连接到接入点一些设备,抛出一个异常调用上FromIdAsync
使用
由于超时时间已过期,此操作返回。(来自HRESULT的异常:0x800705B4)。
反过来,尝试访问接入点的设备将无法连接。
总是无法连接的设备都是相同的,而其他设备连接得很好。我试过有无UI线程,但结果保持不变。我使用的错误吗?还是Wi-Fi Direct中的错误?如果是这样,是否有另一种方法可以在没有UWP API的情况下启动Wi-Fi Direct访问点?也许效果更好。