mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 23:57:22 -08:00
Wi-Fi fix again
This commit is contained in:
parent
fe0e62d672
commit
72322a7fe5
1 changed files with 15 additions and 12 deletions
|
@ -1102,32 +1102,35 @@ namespace {
|
|||
}
|
||||
}
|
||||
global::wifi::wifiState checkWifiState() {
|
||||
QString interfaceStateFileHead = "/sys/class/net/";
|
||||
QString interfaceStateFileTail = "/operstate";
|
||||
QString interfaceName;
|
||||
QString interfaceStateFile;
|
||||
if(global::deviceID == "n437\n" or global::deviceID == "kt\n") {
|
||||
interfaceName = "wlan0";
|
||||
}
|
||||
else {
|
||||
interfaceName = "eth0";
|
||||
}
|
||||
interfaceStateFile = interfaceStateFileHead + interfaceName + interfaceStateFileTail;
|
||||
|
||||
QString state = readFile(interfaceStateFile);
|
||||
if(state == "up\n") {
|
||||
// Check if network interface has an IP address
|
||||
QNetworkInterface iface = QNetworkInterface::interfaceFromName(interfaceName);
|
||||
QList<QNetworkAddressEntry> entries = iface.addressEntries();
|
||||
if(!entries.isEmpty()) {
|
||||
// Interface is up and has an IP address
|
||||
global::wifi::isConnected = true;
|
||||
return global::wifi::wifiState::configured;
|
||||
}
|
||||
else if(state == "unknown\n") {
|
||||
else {
|
||||
if(QFile::exists("/sys/class/net/" + interfaceName + "/operstate")) {
|
||||
// Interface is up but doesn't have an IP address
|
||||
global::wifi::isConnected = false;
|
||||
return global::wifi::wifiState::enabled;
|
||||
}
|
||||
else {
|
||||
// Interface is not up
|
||||
global::wifi::isConnected = false;
|
||||
return global::wifi::wifiState::disabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
int testPing() {
|
||||
// For some reason, implementing a non-blocking version of this functions triggers a "terminate called without an active exception" error with a platform plugin compiled with a newer GCC 11 toolchain. The problem has been solved by transplanting this function into the related area which uses it.
|
||||
QProcess *pingProcess = new QProcess();
|
||||
|
|
Loading…
Reference in a new issue