Optimize algorithm to select wifi
This commit is contained in:
parent
c6b26cdaeb
commit
747685dd0d
|
@ -1831,11 +1831,11 @@ void MainWindow::wifiListOptimize(QStringList& slist)
|
||||||
QStringList targetList; //slist优化,同名同频AP中只留信号最强
|
QStringList targetList; //slist优化,同名同频AP中只留信号最强
|
||||||
targetList<<slist.at(0); //把第一行加进去
|
targetList<<slist.at(0); //把第一行加进去
|
||||||
for(int it = 1;it < slist.size();it++){
|
for(int it = 1;it < slist.size();it++){
|
||||||
QString i = slist.at(it);
|
QString currentWifiInfo = slist.at(it);
|
||||||
bool ifContinue = false;
|
bool ifContinue = false;
|
||||||
QString conName = i.mid(indexName, indexPath - indexName).trimmed();
|
QString conName = currentWifiInfo.mid(indexName, indexPath - indexName).trimmed();
|
||||||
int conSignal = i.mid(indexSignal,3).trimmed().toInt();
|
int conSignal = currentWifiInfo.mid(indexSignal,3).trimmed().toInt();
|
||||||
int conFreq = i.mid(indexFreq,4).trimmed().toInt();
|
int conFreq = currentWifiInfo.mid(indexFreq,4).trimmed().toInt();
|
||||||
for(int i=0;i<slist.size();i++){
|
for(int i=0;i<slist.size();i++){
|
||||||
QString str = slist.at(i);
|
QString str = slist.at(i);
|
||||||
QString name = str.mid(indexName, indexPath - indexName).trimmed();
|
QString name = str.mid(indexName, indexPath - indexName).trimmed();
|
||||||
|
@ -1857,7 +1857,7 @@ void MainWindow::wifiListOptimize(QStringList& slist)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ifContinue) continue;
|
if(ifContinue) continue;
|
||||||
targetList<<i;
|
targetList<<currentWifiInfo;
|
||||||
}
|
}
|
||||||
slist = targetList;
|
slist = targetList;
|
||||||
return ;
|
return ;
|
||||||
|
@ -1903,17 +1903,22 @@ void MainWindow::getFinalWifiList(QStringList &slist)
|
||||||
int signal = wifiStr.mid(indexSignal,3).trimmed().toInt();
|
int signal = wifiStr.mid(indexSignal,3).trimmed().toInt();
|
||||||
int freq = wifiStr.mid(indexFreq,4).trimmed().toInt();
|
int freq = wifiStr.mid(indexFreq,4).trimmed().toInt();
|
||||||
if(conName == name){
|
if(conName == name){
|
||||||
if (conFreq > freq) {
|
if (conFreq >= 5000) {
|
||||||
if ((signal-conSignal) > 50) { //低频的信号格数比高频大于两格,选低频
|
//排在前面的一个是5Gwifi,并且信号也强一些
|
||||||
deleteWifiStr.append(wifiInfo);
|
deleteWifiStr.append(wifiStr);
|
||||||
} else {
|
|
||||||
deleteWifiStr.append(wifiStr);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if ((conSignal-signal) > 50) { //低频的信号格数比高频大于两格,选低频
|
//排在前面的一个是2.4G
|
||||||
deleteWifiStr.append(wifiStr);
|
if (freq >= 5000) {
|
||||||
|
//排在后面的一个是5G
|
||||||
|
if (signal >= 55) {
|
||||||
|
//排在后面的一个是5Gwifi信号强度 >= 3格,选5G
|
||||||
|
deleteWifiStr.append(wifiInfo);
|
||||||
|
} else {
|
||||||
|
deleteWifiStr.append(wifiStr);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
deleteWifiStr.append(wifiInfo);
|
//排在后面的一个是2.4G
|
||||||
|
deleteWifiStr.append(wifiStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue