luci-app-travelmate: sync with travelmate 1.2.0
[project/luci.git] / applications / luci-app-travelmate / luasrc / model / cbi / travelmate / wifi_edit.lua
index 64659d6..f3ad762 100644 (file)
@@ -1,4 +1,4 @@
--- Copyright 2017 Dirk Brenken (dev@brenken.org)
+-- Copyright 2017-2018 Dirk Brenken (dev@brenken.org)
 -- This is free software, licensed under the Apache License, Version 2.0
 
 local fs   = require("nixio.fs")
@@ -22,17 +22,17 @@ local s = uci:get_all("wireless", m.hidden.cfg)
 if s ~= nil then
        wssid = m:field(Value, "ssid", translate("SSID"))
        wssid.datatype = "rangelength(1,32)"
-       wssid.default = s.ssid
+       wssid.default = s.ssid or ""
+
        bssid = m:field(Value, "bssid", translate("BSSID"))
        bssid.datatype = "macaddr"
-       bssid.default = s.bssid
+       bssid.default = s.bssid or ""
 
+       s.cipher = "auto"
        if string.match(s.encryption, '\+') and not string.match(s.encryption, '^wep') then
                s.pos = string.find(s.encryption, '\+')
                s.cipher = string.sub(s.encryption, s.pos + 1)
                s.encryption = string.sub(s.encryption, 0, s.pos - 1)
-       else
-               s.cipher = "auto"
        end
 
        if s.encryption and s.encryption ~= "none" then
@@ -92,6 +92,8 @@ if s ~= nil then
                        authentication:value("EAP-MD5")
                        authentication:value("EAP-MSCHAPV2")
                        authentication:value("EAP-TLS")
+                       authentication:value("auth=PAP")
+                       authentication:value("auth=MSCHAPV2")
                        authentication.default = s.auth or "EAP-MSCHAPV2"
 
                        ident = m:field(Value, "identity", translate("Identity"))
@@ -160,6 +162,7 @@ function wssid.write(self, section, value)
        end
        uci:save("wireless")
        uci:commit("wireless")
+       luci.sys.call("env -i /bin/ubus call network reload >/dev/null 2>&1")
        m.on_cancel()
 end