mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
Wi-Fi fix again
This commit is contained in:
parent
fe0e62d672
commit
72322a7fe5
1 changed files with 15 additions and 12 deletions
|
@ -1102,30 +1102,33 @@ 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") {
|
||||
global::wifi::isConnected = false;
|
||||
return global::wifi::wifiState::enabled;
|
||||
}
|
||||
else {
|
||||
global::wifi::isConnected = false;
|
||||
return global::wifi::wifiState::disabled;
|
||||
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() {
|
||||
|
|
Loading…
Reference in a new issue