From c621c618bd951f7cb5c1974b0e5fc2a5a0e74742 Mon Sep 17 00:00:00 2001 From: peteruithoven Date: Fri, 10 Jan 2014 11:14:17 +0100 Subject: [PATCH] Start access point network services on boot instead of reload --- src/main.lua | 2 +- src/network/netconfig.lua | 13 ++++++++----- src/rest/api/api_network.lua | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main.lua b/src/main.lua index 36e07a2..cd456f3 100644 --- a/src/main.lua +++ b/src/main.lua @@ -94,7 +94,7 @@ local function setupAutoWifiMode() return nil, "autowifi: could not associate with ssid '" .. connectWith .. "' (" .. msg .. ")" end elseif netMode ~= 'ap' or netName ~= apSsid then - local rv,msg = netconf.setupAccessPoint(apSsid) + local rv,msg = netconf.setupAccessPoint(apSsid,true) if rv then return true, "autowifi: configured as access point with ssid '" .. apSsid .. "'" else diff --git a/src/network/netconfig.lua b/src/network/netconfig.lua index 5a1424c..95bff9b 100644 --- a/src/network/netconfig.lua +++ b/src/network/netconfig.lua @@ -275,16 +275,19 @@ end -- Note: this function might belong in the wlanconfig module but that would introduce -- a circular dependency, easiest solution is to place the function here. -- @tparam string ssid The SSID to use for the access point. +-- @tparam boolean boot If true, the components have to start instead of reloaded (only needed on boot) -- @return True on success or nil+msg on error. -function M.setupAccessPoint(ssid) - +function M.setupAccessPoint(ssid,boot) M.setStatus(M.CREATING,"Creating access point '"..ssid.."'..."); + boot = boot or false + if boot then log:info(" boot mode") end - M.switchConfiguration{apnet="add_noreload"} + -- add access point configuration + M.switchConfiguration({apnet="add_noreload"},boot) wifi.activateConfig(ssid) -- NOTE: dnsmasq must be reloaded after network or it will be unable to serve IP addresses - M.switchConfiguration{ wifiiface="add", network="reload", staticaddr="add", dhcppool="add_noreload", wwwredir="add", dnsredir="add" } - M.switchConfiguration{dhcp="reload"} + M.switchConfiguration({ wifiiface="add", network="reload", staticaddr="add", dhcppool="add_noreload", wwwredir="add", dnsredir="add" },boot) + M.switchConfiguration({dhcp="reload"},boot) M.setStatus(M.CREATED,"Access point created"); diff --git a/src/rest/api/api_network.lua b/src/rest/api/api_network.lua index e29d1d5..5fc5ba6 100644 --- a/src/rest/api/api_network.lua +++ b/src/rest/api/api_network.lua @@ -147,7 +147,7 @@ function M.associate_POST(request, response) response:setSuccess("wlan is trying to associate") - local rv,msg = netconf.associateSsid(argSsid, argPhrase, argRecreate) + local rv,msg = netconf.associateSsid(argSsid, argPhrase, argRecreate,false) if rv then log:info("associated to wifi: "..utils.dump(argSsid)) else