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,23 +1102,32 @@ namespace {
}
}
global::wifi::wifiState checkWifiState() {
foreach(QNetworkInterface interface, QNetworkInterface::allInterfaces()) {
// If something is wrong, debug with this:
// qDebug() << interface;
if(interface.flags().testFlag(QNetworkInterface::IsLoopBack) == false) {
if(interface.flags().testFlag(QNetworkInterface::IsUp) == true) {
if(interface.flags().testFlag(QNetworkInterface::IsRunning) == true) {
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") {
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;
}
}
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();

View file

@ -370,8 +370,8 @@ void connectiondialog::finalConnectWait() {
else {
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
log("Writing to config directory with connection information data", className);
// 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 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/passphrase", passphraseForReconnecting.toStdString());