0
0
mirror of https://github.com/Doodle3D/doodle3d-firmware.git synced 2025-01-03 08:13:49 +01:00

Add option to create protected access point.

This commit is contained in:
Wouter R 2013-10-14 14:01:22 +02:00
parent 369866ce60
commit 9d86ed2aac
2 changed files with 10 additions and 1 deletions

View File

@ -43,6 +43,12 @@ M.network_ap_address = {
regex = '%d+\.%d+\.%d+\.%d+' regex = '%d+\.%d+\.%d+\.%d+'
} }
M.network_ap_key = {
default = '',
type = 'string',
description = 'Access Point security key'
}
M.network_ap_netmask = { M.network_ap_netmask = {
default = '255.255.255.0', default = '255.255.255.0',
type = 'string', type = 'string',

View File

@ -107,16 +107,19 @@ end
function reconf.apnet_add_noreload(dirtyList) reconf.apnet_add(dirtyList, true) end function reconf.apnet_add_noreload(dirtyList) reconf.apnet_add(dirtyList, true) end
function reconf.apnet_add(dirtyList, noReload) function reconf.apnet_add(dirtyList, noReload)
local ourSsid = wifi.getSubstitutedSsid(settings.get('network.ap.ssid')) local ourSsid = wifi.getSubstitutedSsid(settings.get('network.ap.ssid'))
local networkKey = settings.get('network.ap.key')
local sname = nil local sname = nil
uci:foreach('wireless', 'wifi-iface', function(s) uci:foreach('wireless', 'wifi-iface', function(s)
if s.ssid == ourSsid then sname = s['.name']; return false end if s.ssid == ourSsid then sname = s['.name']; return false end
end) end)
if sname == nil then sname = uci:add('wireless', 'wifi-iface') end if sname == nil then sname = uci:add('wireless', 'wifi-iface') end
local encType = networkKey == '' and 'none' or 'psk2'
M.uciTableSet('wireless', sname, { M.uciTableSet('wireless', sname, {
network = wifi.NET, network = wifi.NET,
ssid = ourSsid, ssid = ourSsid,
encryption = 'none', encryption = encType,
key = networkKey,
device = 'radio0', device = 'radio0',
mode = 'ap', mode = 'ap',
}) })