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,30 +1102,33 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
global::wifi::wifiState checkWifiState() {
|
global::wifi::wifiState checkWifiState() {
|
||||||
QString interfaceStateFileHead = "/sys/class/net/";
|
|
||||||
QString interfaceStateFileTail = "/operstate";
|
|
||||||
QString interfaceName;
|
QString interfaceName;
|
||||||
QString interfaceStateFile;
|
|
||||||
if(global::deviceID == "n437\n" or global::deviceID == "kt\n") {
|
if(global::deviceID == "n437\n" or global::deviceID == "kt\n") {
|
||||||
interfaceName = "wlan0";
|
interfaceName = "wlan0";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
interfaceName = "eth0";
|
interfaceName = "eth0";
|
||||||
}
|
}
|
||||||
interfaceStateFile = interfaceStateFileHead + interfaceName + interfaceStateFileTail;
|
|
||||||
|
|
||||||
QString state = readFile(interfaceStateFile);
|
// Check if network interface has an IP address
|
||||||
if(state == "up\n") {
|
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;
|
global::wifi::isConnected = true;
|
||||||
return global::wifi::wifiState::configured;
|
return global::wifi::wifiState::configured;
|
||||||
}
|
}
|
||||||
else if(state == "unknown\n") {
|
|
||||||
global::wifi::isConnected = false;
|
|
||||||
return global::wifi::wifiState::enabled;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
global::wifi::isConnected = false;
|
if(QFile::exists("/sys/class/net/" + interfaceName + "/operstate")) {
|
||||||
return global::wifi::wifiState::disabled;
|
// 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() {
|
int testPing() {
|
||||||
|
|
Loading…
Reference in a new issue