Merge pull request #147 from mammonsama666/fix-wpa3

fix(wifi): WPA3 can not be connected successfully.
This commit is contained in:
chenlelin 2021-05-28 14:55:06 +08:00 committed by GitHub
commit 886e3e97a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 9 deletions

View File

@ -286,18 +286,24 @@ void BackThread::dellConnectLanResult(QString info)
}
//to connected wireless network need a password
void BackThread::execConnWifiPWD(QString connName, QString password, QString connType)
void BackThread::execConnWifiPWD(QString connName, QString password, QString connType, QString security)
{
//disConnLanOrWifi("wifi");
if (!connType.isEmpty()) {
QString strConntype = "nmcli connection modify '" + connName + "' wifi-sec.psk-flags 0";
Utils::m_system(strConntype.toUtf8().data());
}
QString tmpPath = "/tmp/kylin-nm-btoutput-" + QDir::home().dirName();
QString cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli device wifi connect '" + connName + "' password '" + password + "' > " + tmpPath;
Utils::m_system(cmdStr.toUtf8().data());
if (security.contains("WPA3")) {
QString create_cmd = QString("nmcli connection add con-name %1 type wifi 802-11-wireless-security.key-mgmt sae ssid %2 802-11-wireless-security.psk %3").arg(connName).arg(connName).arg(password);
Utils::m_system(create_cmd.toUtf8().data());
QString connect_cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "' > " + tmpPath;
Utils::m_system(connect_cmdStr.toUtf8().data());
} else {
QString cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli device wifi connect '" + connName + "' password '" + password + "' > " + tmpPath;
Utils::m_system(cmdStr.toUtf8().data());
}
QFile file(tmpPath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {

View File

@ -61,7 +61,7 @@ public slots:
void execConnLan(QString connName, QString ifname, QString connectType);
void execConnWifi(QString connName, QString connIfName);
void execReconnWIfi(QString uuid);
void execConnWifiPWD(QString connName, QString password, QString connType);
void execConnWifiPWD(QString connName, QString password, QString connType, QString security);
void execConnWifiPsk(QString cmd);
void execConnHiddenWifiWPA(QString connName, QString password);
void execConnRememberedHiddenWifi(QString connName);

View File

@ -554,7 +554,7 @@ void OneConnForm::slotConnWifi()
void OneConnForm::slotConnWifiPWD()
{
this->startWifiWaiting(true);
emit sigConnWifiPWD(wifiName, ui->lePassword->text(), connType);
emit sigConnWifiPWD(wifiName, ui->lePassword->text(), connType, wifiSecu);
}
//点击后断开wifi网络
@ -814,8 +814,8 @@ void OneConnForm::on_btnConnPWD_clicked()
bt->moveToThread(t);
connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
connect(t, SIGNAL(started()), this, SLOT(slotConnWifiPWD()));
connect(this, SIGNAL(sigConnWifiPWD(QString, QString, QString)),
bt, SLOT(execConnWifiPWD(QString, QString, QString)));
connect(this, SIGNAL(sigConnWifiPWD(QString, QString, QString, QString)),
bt, SLOT(execConnWifiPWD(QString, QString, QString, QString)));
connect(bt, SIGNAL(connDone(int)), mw, SLOT(connWifiDone(int)));
connect(bt, SIGNAL(connDone(int)), this, SLOT(slotConnWifiResult(int)));
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));

View File

@ -164,7 +164,7 @@ signals:
void requestRefreshWifiList();
void sigConnWifi(QString, QString);
void sigConnWifiPWD(QString, QString, QString);
void sigConnWifiPWD(QString, QString, QString, QString);
void sigConnWifiPsk(QString);
};