From fa91ace160287ec93a99590803b0ff2d98c7561c Mon Sep 17 00:00:00 2001 From: olijf Date: Wed, 23 Mar 2016 13:33:14 +0100 Subject: [PATCH 1/4] Fixed wifi issue Different approach different solution. Instead of using the API to govern whether or not connection was succesful the netconfig.lua figurers this out. --- src/network/netconfig.lua | 4 ++++ src/network/wlanconfig.lua | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/network/netconfig.lua b/src/network/netconfig.lua index 60bb5fb..170aa05 100644 --- a/src/network/netconfig.lua +++ b/src/network/netconfig.lua @@ -386,7 +386,11 @@ function M.associateSsid(ssid, passphrase, recreate) if attempt >= maxAttempts then -- still no correct ssid; fail local msg = "Could not associate with network (incorrect password?)" + wifi.removeConfig(ssid) M.setStatus(M.CONNECTING_FAILED,msg); + local backupssid = wifi.getSubstitutedSsid(settings.get('network.ap.ssid')) + M.setupAccessPoint(backupssid) + M.enableAccessPoint(backupssid) return false, msg else nextAttemptTime = os.time() + attemptInterval diff --git a/src/network/wlanconfig.lua b/src/network/wlanconfig.lua index b7bff30..77ee5fe 100644 --- a/src/network/wlanconfig.lua +++ b/src/network/wlanconfig.lua @@ -177,11 +177,16 @@ end function M.removeConfig(ssid) local rv = false uci:foreach('wireless', 'wifi-iface', function(s) + log:info(MOD_ABBR, utils.dump(s.ssid).."\n "..utils.dump(s)) if s.ssid == ssid then - uci:delete('wireless', s['.name']) - rv = true + log:info(MOD_ABBR, "deleting faulty ssid: "..utils.dump(s['.name'])) + rv = uci:delete('wireless', s['.name']) + end + if s.disabled == 1 then + M.activateConfig(s.ssid) end end) + uci:save('wireless') uci:commit('wireless') return rv end From c6b01a3cf773fbb8a181d3b3cbecb435dc6a4388 Mon Sep 17 00:00:00 2001 From: olijf Date: Wed, 30 Mar 2016 11:10:44 +0200 Subject: [PATCH 2/4] switched responsibilities moved the Open Acces point code to the rest API because we dont wish to change setting during boot. (other issues arise now eg: what to do when someone changes his wifi password? box does nog connect but also does not open AP) --- src/network/netconfig.lua | 4 ---- src/network/wlanconfig.lua | 3 --- src/rest/api/api_network.lua | 4 ++++ 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/network/netconfig.lua b/src/network/netconfig.lua index 170aa05..60bb5fb 100644 --- a/src/network/netconfig.lua +++ b/src/network/netconfig.lua @@ -386,11 +386,7 @@ function M.associateSsid(ssid, passphrase, recreate) if attempt >= maxAttempts then -- still no correct ssid; fail local msg = "Could not associate with network (incorrect password?)" - wifi.removeConfig(ssid) M.setStatus(M.CONNECTING_FAILED,msg); - local backupssid = wifi.getSubstitutedSsid(settings.get('network.ap.ssid')) - M.setupAccessPoint(backupssid) - M.enableAccessPoint(backupssid) return false, msg else nextAttemptTime = os.time() + attemptInterval diff --git a/src/network/wlanconfig.lua b/src/network/wlanconfig.lua index 77ee5fe..4731aab 100644 --- a/src/network/wlanconfig.lua +++ b/src/network/wlanconfig.lua @@ -182,9 +182,6 @@ function M.removeConfig(ssid) log:info(MOD_ABBR, "deleting faulty ssid: "..utils.dump(s['.name'])) rv = uci:delete('wireless', s['.name']) end - if s.disabled == 1 then - M.activateConfig(s.ssid) - end end) uci:save('wireless') uci:commit('wireless') diff --git a/src/rest/api/api_network.lua b/src/rest/api/api_network.lua index 2c4992a..2570b49 100644 --- a/src/rest/api/api_network.lua +++ b/src/rest/api/api_network.lua @@ -154,6 +154,10 @@ function M.associate_POST(request, response) log:info(MOD_ABBR, "associated to wifi: "..utils.dump(argSsid)) else log:info(MOD_ABBR, "failed to associate to wifi: "..utils.dump(argSsid).." ("..utils.dump(msg)..")") + local backupssid = wifi.getSubstitutedSsid(settings.get('network.ap.ssid')) + netconf.setupAccessPoint(backupssid) + netconf.enableAccessPoint(backupssid) + wifi.removeConfig(argSsid) end end From 0d9684bfcafa7e96000412488c9ccd4a7908c982 Mon Sep 17 00:00:00 2001 From: olijf Date: Wed, 30 Mar 2016 11:23:27 +0200 Subject: [PATCH 3/4] seems the removeConfig needs to be called twice --- src/rest/api/api_network.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rest/api/api_network.lua b/src/rest/api/api_network.lua index 2570b49..73c8264 100644 --- a/src/rest/api/api_network.lua +++ b/src/rest/api/api_network.lua @@ -154,6 +154,7 @@ function M.associate_POST(request, response) log:info(MOD_ABBR, "associated to wifi: "..utils.dump(argSsid)) else log:info(MOD_ABBR, "failed to associate to wifi: "..utils.dump(argSsid).." ("..utils.dump(msg)..")") + wifi.removeConfig(argSsid) local backupssid = wifi.getSubstitutedSsid(settings.get('network.ap.ssid')) netconf.setupAccessPoint(backupssid) netconf.enableAccessPoint(backupssid) From 40a25789e256745b441741dd56b6fdcbd5725fac Mon Sep 17 00:00:00 2001 From: olijf Date: Wed, 30 Mar 2016 15:57:00 +0200 Subject: [PATCH 4/4] changed log level on removeConfig --- src/network/wlanconfig.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/wlanconfig.lua b/src/network/wlanconfig.lua index 4731aab..151f221 100644 --- a/src/network/wlanconfig.lua +++ b/src/network/wlanconfig.lua @@ -177,9 +177,9 @@ end function M.removeConfig(ssid) local rv = false uci:foreach('wireless', 'wifi-iface', function(s) - log:info(MOD_ABBR, utils.dump(s.ssid).."\n "..utils.dump(s)) + log:verbose(MOD_ABBR, utils.dump(s.ssid).."\n "..utils.dump(s)) if s.ssid == ssid then - log:info(MOD_ABBR, "deleting faulty ssid: "..utils.dump(s['.name'])) + log:verbose(MOD_ABBR, "deleting faulty ssid: "..utils.dump(s['.name'])) rv = uci:delete('wireless', s['.name']) end end)