问题描述
我正在实现一个将手机连接到特定SSID的APP。通过Xamarin。
APP将检查连接是否完成。
如何快速进行检查?
以下是我当前的代码。
从开始到结束。我在一个良好的环境中进行了测试(手机可以很容易地对准目标SSID)
大约需要6秒钟。是否有可能使速度更快?
//Use this to connect to SSID
var config = new NEHotspotConfiguration(SSID,Password,isWep: false)
config.JoinOnce = false;
var tcs = new taskcompletionsource<NSError>();
NEHotspotConfigurationManager.SharedManager.ApplyConfiguration(config,err => tcs.SetResult(err));
//Use this to check connection is done or not
while(Get_Current_Connected_SSID() != SSID)
{
Task.Delay(TimeSpan.FromMilliseconds(200));
}
public string Get_Current_Connected_SSID()
{
String ssid = "";
try
{
string[] supportedInterfaces;
StatusCode status;
if ((status = captivenetwork.TryGetSupportedInterfaces(out supportedInterfaces)) != StatusCode.OK)
{
}
else
{
foreach (var item in supportedInterfaces)
{
NSDictionary info;
status = captivenetwork.TrycopyCurrentNetworkInfo(item,out info);
if (status != StatusCode.OK)
{
continue;
}
ssid = info[captivenetwork.NetworkInfoKeySSID].ToString();
}
}
}
catch
{
}
return ssid;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)