Wi-Fi fix

This commit is contained in:
Nicolas Mailloux 2023-06-09 10:17:37 -04:00
parent af75ba1969
commit fe0e62d672
2 changed files with 26 additions and 17 deletions

View file

@ -1102,22 +1102,31 @@ namespace {
} }
} }
global::wifi::wifiState checkWifiState() { global::wifi::wifiState checkWifiState() {
foreach(QNetworkInterface interface, QNetworkInterface::allInterfaces()) { QString interfaceStateFileHead = "/sys/class/net/";
// If something is wrong, debug with this: QString interfaceStateFileTail = "/operstate";
// qDebug() << interface; QString interfaceName;
if(interface.flags().testFlag(QNetworkInterface::IsLoopBack) == false) { QString interfaceStateFile;
if(interface.flags().testFlag(QNetworkInterface::IsUp) == true) { if(global::deviceID == "n437\n" or global::deviceID == "kt\n") {
if(interface.flags().testFlag(QNetworkInterface::IsRunning) == true) { interfaceName = "wlan0";
global::wifi::isConnected = true; }
return global::wifi::wifiState::configured; else {
} interfaceName = "eth0";
global::wifi::isConnected = false; }
return global::wifi::wifiState::enabled; interfaceStateFile = interfaceStateFileHead + interfaceName + interfaceStateFileTail;
}
} QString state = readFile(interfaceStateFile);
if(state == "up\n") {
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;
} }
global::wifi::isConnected = false;
return global::wifi::wifiState::disabled;
} }
int testPing() { 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. // 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.

View file

@ -370,8 +370,8 @@ void connectiondialog::finalConnectWait() {
else { else {
string_writeconfig("/opt/ibxd", "connect_to_wifi_network\n"); string_writeconfig("/opt/ibxd", "connect_to_wifi_network\n");
// This will be deleted later in MainWindow's icon updater if it failed. It is also deleted in the Wi-Fi stop script // This will be deleted later in MainWindow's icon updater if it failed. It is also deleted in the Wi-Fi stop script.
log("Writing to config directory with connection information data", className); log("Writing to configuration directory with connection information data", className);
string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid", connectedNetworkData.name.toStdString()); string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid", connectedNetworkData.name.toStdString());
string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/passphrase", passphraseForReconnecting.toStdString()); string_writeconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/passphrase", passphraseForReconnecting.toStdString());