Skip to content
This repository was archived by the owner on Jan 28, 2022. It is now read-only.

Commit d5b73cb

Browse files
authored
fix: Clear wifi networks in initial setup (#516)
This closes #511
1 parent 45f8f9e commit d5b73cb

File tree

5 files changed

+21
-16
lines changed

5 files changed

+21
-16
lines changed

setup/SetupStep3.qml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@ import WifiControl 1.0
2828

2929
import "qrc:/basic_ui" as BasicUI
3030

31+
// TODO(marton) back swipe or button to choose language / country setting again
3132
Item {
3233
id: container
3334
width: 480; height: 800
3435

3536
Component.onCompleted: {
37+
// TODO(marton) check if Wifi connection is already established and ask user to use it, or to set it up again.
38+
// This state can happen through a reboot during a previous setup process.
39+
// Connection check: wifi.wifiStatus.connected
3640
networkScanTimer.start();
3741
}
3842

setup/SetupStep4.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Rectangle {
4646
swipeViewObj.parent.parent.wifiPassword = passwordField.text;
4747
swipeViewObj.parent.parent.wifiSsid = name;
4848

49+
wifi.clearConfiguredNetworks();
4950
wifi.join(name, passwordField.text, security);
5051
inputPanel.active = false;
5152
container.state = "closed";

setup/SetupStep4Other.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Rectangle {
5353
security = WifiSecurity.DEFAULT;
5454
}
5555

56+
wifi.clearConfiguredNetworks();
5657
wifi.join(name, passwordField.text, security);
5758
inputPanel.active = false;
5859
container.state = "closed";

sources/hardware/linux/wifi_wpasupplicant.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,18 @@ bool WifiWpaSupplicant::clearConfiguredNetworks() {
158158

159159
setConnected(false);
160160

161-
if (!controlRequest("REMOVE_NETWORK all")) {
162-
return false;
163-
}
161+
bool ret = false;
162+
if (controlRequest("REMOVE_NETWORK all") && saveConfiguration()) {
163+
stopScanTimer();
164164

165-
if (!saveConfiguration()) {
166-
return false;
165+
qCInfo(lcWifiWpaCtrl) << "Disconnected, all networks removed and cleared configuration";
166+
ret = true;
167167
}
168168

169-
stopScanTimer();
170-
171-
qCInfo(lcWifiWpaCtrl) << "All networks removed and disconnected";
172-
173-
return true;
169+
// avoid deadlock.
170+
// DISCONNECT doc states: "Disconnect and wait for REASSOCIATE or RECONNECT command before connecting."
171+
controlRequest("RECONNECT");
172+
return ret;
174173
}
175174

176175
bool WifiWpaSupplicant::join(const QString& ssid, const QString& password, WifiSecurity::Enum security) {

translations/en_US.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -856,36 +856,36 @@ Navigate your internet browser to: http://</source>
856856
<context>
857857
<name>SetupStep3</name>
858858
<message>
859-
<location filename="../setup/SetupStep3.qml" line="63"/>
859+
<location filename="../setup/SetupStep3.qml" line="67"/>
860860
<source>Wi-Fi setup</source>
861861
<translation type="unfinished"></translation>
862862
</message>
863863
<message>
864-
<location filename="../setup/SetupStep3.qml" line="74"/>
864+
<location filename="../setup/SetupStep3.qml" line="78"/>
865865
<source>Select a Wi-Fi network.</source>
866866
<translation type="unfinished"></translation>
867867
</message>
868868
<message>
869-
<location filename="../setup/SetupStep3.qml" line="166"/>
869+
<location filename="../setup/SetupStep3.qml" line="170"/>
870870
<source>Join other</source>
871871
<translation type="unfinished"></translation>
872872
</message>
873873
</context>
874874
<context>
875875
<name>SetupStep4</name>
876876
<message>
877-
<location filename="../setup/SetupStep4.qml" line="97"/>
877+
<location filename="../setup/SetupStep4.qml" line="98"/>
878878
<source>Enter password for
879879
&quot;%1&quot;</source>
880880
<translation type="unfinished"></translation>
881881
</message>
882882
<message>
883-
<location filename="../setup/SetupStep4.qml" line="115"/>
883+
<location filename="../setup/SetupStep4.qml" line="116"/>
884884
<source>Password</source>
885885
<translation type="unfinished"></translation>
886886
</message>
887887
<message>
888-
<location filename="../setup/SetupStep4.qml" line="174"/>
888+
<location filename="../setup/SetupStep4.qml" line="175"/>
889889
<source>Join</source>
890890
<translation type="unfinished"></translation>
891891
</message>

0 commit comments

Comments
 (0)