diff --git a/src/conf_defaults.lua b/src/conf_defaults.lua index ac24151..9dedf8d 100644 --- a/src/conf_defaults.lua +++ b/src/conf_defaults.lua @@ -43,6 +43,12 @@ M.network_ap_address = { regex = '%d+\.%d+\.%d+\.%d+' } +M.network_ap_key = { + default = '', + type = 'string', + description = 'Access Point security key' +} + M.network_ap_netmask = { default = '255.255.255.0', type = 'string', diff --git a/src/network/netconfig.lua b/src/network/netconfig.lua index 5536ef8..4222720 100644 --- a/src/network/netconfig.lua +++ b/src/network/netconfig.lua @@ -107,16 +107,19 @@ end function reconf.apnet_add_noreload(dirtyList) reconf.apnet_add(dirtyList, true) end function reconf.apnet_add(dirtyList, noReload) local ourSsid = wifi.getSubstitutedSsid(settings.get('network.ap.ssid')) + local networkKey = settings.get('network.ap.key') local sname = nil uci:foreach('wireless', 'wifi-iface', function(s) if s.ssid == ourSsid then sname = s['.name']; return false end end) if sname == nil then sname = uci:add('wireless', 'wifi-iface') end + local encType = networkKey == '' and 'none' or 'psk2' M.uciTableSet('wireless', sname, { network = wifi.NET, ssid = ourSsid, - encryption = 'none', + encryption = encType, + key = networkKey, device = 'radio0', mode = 'ap', })