Wi-Fi: Fixes

This commit is contained in:
Nicolas Mailloux 2022-08-22 23:52:57 -04:00
parent edffb452bd
commit 3116d7d918
4 changed files with 16 additions and 19 deletions

View file

@ -778,13 +778,12 @@ void MainWindow::updateWifiIcon() {
if(currentWifiState == global::wifi::wifiState::disabled) { if(currentWifiState == global::wifi::wifiState::disabled) {
if(isConnecting == true) { if(isConnecting == true) {
if(checkconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped") == false) { if(checkconfig("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped") == false) {
QString wifiName = readFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid").replace("\n", "");
if(isReconnecting == true) { if(isReconnecting == true) {
showToast("Failed to reconnnect to " + wifiName); showToast("Reconnection failed");
isReconnecting = false; isReconnecting = false;
} }
else { else {
showToast("Failed to connect to " + wifiName); showToast("Connection failed");
} }
isConnecting = false; isConnecting = false;
QFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid").remove(); QFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid").remove();
@ -806,13 +805,12 @@ void MainWindow::updateWifiIcon() {
if(currentWifiState == global::wifi::wifiState::configured) { if(currentWifiState == global::wifi::wifiState::configured) {
if(isConnecting == true) { if(isConnecting == true) {
setDefaultWorkDir(); setDefaultWorkDir();
QString wifiName = readFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/essid").replace("\n", "");
if(isReconnecting == true) { if(isReconnecting == true) {
showToast("Reconnected successfully to " + wifiName); showToast("Reconnection successful");
isReconnecting = false; isReconnecting = false;
} }
else { else {
showToast("Connected successfully to " + wifiName); showToast("Connection successful");
} }
isConnecting = false; isConnecting = false;
QFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped").remove(); QFile("/mnt/onboard/.adds/inkbox/.config/17-wifi_connection_information/stopped").remove();

View file

@ -73,13 +73,13 @@ void network::applyVariables() {
if(mainData.signal >= 0 and mainData.signal <= 25) { if(mainData.signal >= 0 and mainData.signal <= 25) {
ui->signalStrengthIcon->setIcon(QIcon(":/resources/wifi-0.png")); ui->signalStrengthIcon->setIcon(QIcon(":/resources/wifi-0.png"));
} }
else if(mainData.signal >= 25 and mainData.signal <= 50) { else if(mainData.signal >= 25 and mainData.signal < 50) {
ui->signalStrengthIcon->setIcon(QIcon(":/resources/wifi-25.png")); ui->signalStrengthIcon->setIcon(QIcon(":/resources/wifi-25.png"));
} }
else if(mainData.signal >= 50 and mainData.signal <= 75) { else if(mainData.signal >= 50 and mainData.signal < 75) {
ui->signalStrengthIcon->setIcon(QIcon(":/resources/wifi-50.png")); ui->signalStrengthIcon->setIcon(QIcon(":/resources/wifi-50.png"));
} }
else if(mainData.signal >= 75 and mainData.signal <= 100) { else if(mainData.signal >= 75 and mainData.signal < 100) {
ui->signalStrengthIcon->setIcon(QIcon(":/resources/wifi-75.png")); ui->signalStrengthIcon->setIcon(QIcon(":/resources/wifi-75.png"));
} }
else if(mainData.signal == 100) { else if(mainData.signal == 100) {

View file

@ -51,16 +51,16 @@
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin"> <property name="leftMargin">
<number>12</number> <number>16</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>3</number> <number>10</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>3</number> <number>3</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>3</number> <number>10</number>
</property> </property>
<item> <item>
<widget class="QPushButton" name="signalStrengthIcon"> <widget class="QPushButton" name="signalStrengthIcon">

View file

@ -91,8 +91,7 @@ void wifiDialog::on_refreshBtn_clicked()
if(checkWifiState() == global::wifi::wifiState::disabled) { if(checkWifiState() == global::wifi::wifiState::disabled) {
if(refreshFromWatcher == true) { if(refreshFromWatcher == true) {
refreshFromWatcher = false; refreshFromWatcher = false;
emit showToast("To scan, turn on wi-fi first"); emit showToast("To scan, turn Wi-Fi on first");
log("To scan, turn on wi-fi first", className);
} }
} }
else { else {
@ -159,7 +158,7 @@ void wifiDialog::refreshNetworksList() {
log("Network name is empty", className); log("Network name is empty", className);
} }
else { else {
log("Network name is: " + singleData, className); log("Network name is: '" + singleData + "'", className);
} }
singleNetwork.name = singleData; singleNetwork.name = singleData;
} }
@ -297,11 +296,11 @@ void wifiDialog::on_wifiCheckBox_stateChanged(int arg1)
{ {
if(ignoreCheckBoxCall == false) { if(ignoreCheckBoxCall == false) {
connectedNetworkDataParentSet = false; connectedNetworkDataParentSet = false;
log("wifi dialog clicked: " + QString::number(arg1), className); log("Wi-Fi dialog checkbox clicked: " + QString::number(arg1), className);
if(wifiButtonEnabled == true) { if(wifiButtonEnabled == true) {
if(arg1 == 2) { if(arg1 == 2) {
log("Turning Wi-Fi on", className); log("Turning Wi-Fi on", className);
// the watcher will scan wifi // The watcher will scan Wi-Fi
QTimer::singleShot(0, this, SLOT(turnOnWifi())); QTimer::singleShot(0, this, SLOT(turnOnWifi()));
ui->stopBtn->setStyleSheet("background-color: white;"); ui->stopBtn->setStyleSheet("background-color: white;");
ui->stopBtn->setEnabled(true); ui->stopBtn->setEnabled(true);
@ -373,7 +372,7 @@ void wifiDialog::refreshScreenSlot() {
* get_dhcp.sh - Gets dhcp addresses * get_dhcp.sh - Gets dhcp addresses
* prepare_changing_wifi.sh - Kills everything, prepares to changing network * prepare_changing_wifi.sh - Kills everything, prepares to changing network
* smarter_time_sync.sh - Syncs time * smarter_time_sync.sh - Syncs time
* toggle.sh - Turns on/off Wi-Fi adapter * toggle.sh - Turns Wi-Fi adapter on/off
* list_networks - Lists networks * list_networks - Lists networks
* check_wifi_passphrase.sh - Checks Wi-Fi network passphrase * check_wifi_passphrase.sh - Checks Wi-Fi network passphrase
* watcher() first watches at processes that could kill other ones * watcher() first watches at processes that could kill other ones