更换无线网络信道查找接口,解决信道是165时显示为196的BUG

This commit is contained in:
chenxuechao 2023-06-28 10:07:36 +08:00
parent ae22eb4611
commit d0d875f9ae
2 changed files with 90 additions and 3 deletions

View File

@ -316,6 +316,91 @@ bool KyNetworkDeviceResourse::getActiveConnectionInfo(const QString devName, int
}
}
const QMap<uint, uint> g_bFreqs = {
{2412, 1},
{2417, 2},
{2422, 3},
{2427, 4},
{2432, 5},
{2437, 6},
{2442, 7},
{2447, 8},
{2452, 9},
{2457, 10},
{2462, 11},
{2467, 12},
{2472, 13},
{2484, 14}
};
const QMap<uint, uint> g_aFreqs = {
{5035, 7},
{5040, 8},
{5045, 9},
{5055, 11},
{5060, 12},
{5080, 16},
{5170, 34},
{5180, 36},
{5190, 38},
{5200, 40},
{5210, 42},
{5220, 44},
{5230, 46},
{5240, 48},
{5260, 52},
{5280, 56},
{5300, 60},
{5320, 64},
{5500, 100},
{5520, 104},
{5540, 108},
{5560, 112},
{5580, 116},
{5600, 120},
{5620, 124},
{5640, 128},
{5660, 132},
{5680, 136},
{5700, 140},
{5745, 149},
{5765, 153},
{5785, 157},
{5805, 161},
{5825, 165},
{4915, 183},
{4920, 184},
{4925, 185},
{4935, 187},
{4940, 188},
{4945, 189},
{4960, 192},
{4980, 196}
};
uint KyNetworkDeviceResourse::kyFindChannel(uint freq)
{
uint channel = 0;
QMap<uint, uint> freqMap;
if (freq < 2500) {
freqMap = g_bFreqs;
} else {
freqMap = g_aFreqs;
}
for (auto freqKey : freqMap.keys()) {
if (freqKey <= freq) {
channel = freqMap.value(freqKey);
if (freqKey == freq) {
break;
}
} else {
break;
}
}
return channel;
}
void KyNetworkDeviceResourse::getDeviceActiveAPInfo(const QString devName, QString &strMac, uint &iHz, uint &iChan, QString &secuType)
{
strMac.clear();
@ -342,7 +427,7 @@ void KyNetworkDeviceResourse::getDeviceActiveAPInfo(const QString devName, QStri
}
strMac = apPtr->hardwareAddress();
iHz = apPtr->frequency();
iChan = NetworkManager::findChannel(iHz);
iChan = kyFindChannel(iHz);
NetworkManager::AccessPoint::Capabilities cap = apPtr->capabilities();
NetworkManager::AccessPoint::WpaFlags wpaFlag = apPtr->wpaFlags();
NetworkManager::AccessPoint::WpaFlags rsnFlag = apPtr->rsnFlags();

View File

@ -74,12 +74,14 @@ public:
void getDeviceConnectivity(const QString &deviceName, NetworkManager::Connectivity &connectivity);
private:
void initDeviceMap();
uint kyFindChannel(uint freq);
private:
KyWiredConnectOperation wiredOperation;
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
QStringList m_activeConnectUuidList;
QMap<QString, QString> m_deviceMap;
void initDeviceMap();
};
#endif // KYLINNETORKDEVICERESOURCE_H