From 6f431942cc71000ea4e67d6c99f0b3cd880edd37 Mon Sep 17 00:00:00 2001 From: Wouter R Date: Tue, 20 Aug 2013 21:53:36 +0200 Subject: [PATCH] Fix dhcp address serving in AP mode; small fix in printer API. --- src/network/netconfig.lua | 9 +++++++-- src/rest/api/api_network.lua | 4 +++- src/rest/api/api_printer.lua | 7 +++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/network/netconfig.lua b/src/network/netconfig.lua index 506fc0c..2d2efe9 100644 --- a/src/network/netconfig.lua +++ b/src/network/netconfig.lua @@ -86,6 +86,9 @@ function reconf.network_reload(dirtyList) reloadBit(dirtyList, 'network') end --[[ Issue '/etc/init.d/wireless reload' command ]] function reconf.wireless_reload(dirtyList) reloadBit(dirtyList, 'wireless') end +--[[ Issue '/etc/init.d/dnsmasq reload' command ]] +function reconf.dhcp_reload(dirtyList) reloadBit(dirtyList, 'dnsmasq') end + --[[ Add wlan interface declaration to /etc/config/network ]] function reconf.wifiiface_add(dirtyList) uci:set('network', wifi.NET, 'interface') @@ -149,7 +152,8 @@ end --[[ Add/remove DHCP pool for wireless net ]] -function reconf.dhcppool_add(dirtyList) +function reconf.dhcppool_add_noreload(dirtyList) reconf.dhcppool_add(dirtyList, true) end +function reconf.dhcppool_add(dirtyList, noReload) uci:set('dhcp', wifi.NET, 'dhcp') --create section M.uciTableSet('dhcp', wifi.NET, { interface = wifi.NET, @@ -157,7 +161,8 @@ function reconf.dhcppool_add(dirtyList) limit = '150', leasetime = '12h', }) - commitBit(dirtyList, 'dhcp'); reloadBit(dirtyList, 'dnsmasq') + commitBit(dirtyList, 'dhcp'); + if noReload == nil or noReload == false then reloadBit(dirtyList, 'dnsmasq') end end function reconf.dhcppool_rm(dirtyList) uci:delete('dhcp', wifi.NET) diff --git a/src/rest/api/api_network.lua b/src/rest/api/api_network.lua index 62574c3..4787345 100644 --- a/src/rest/api/api_network.lua +++ b/src/rest/api/api_network.lua @@ -145,7 +145,9 @@ function M.openap_POST(request, response) local ssid = wifi.getSubstitutedSsid(settings.get('network.ap.ssid')) netconf.switchConfiguration{apnet="add_noreload"} wifi.activateConfig(ssid) - netconf.switchConfiguration{ wifiiface="add", network="reload", staticaddr="add", dhcppool="add", wwwredir="add", dnsredir="add" } + -- NOTE: dnsmasq must be reloaded after network or it will be unable to serve IP addresses + netconf.switchConfiguration{ wifiiface="add", network="reload", staticaddr="add", dhcppool="add_noreload", wwwredir="add", dnsredir="add" } + netconf.switchConfiguration{dhcp="reload"} response:setSuccess("switched to Access Point mode") response:addData("ssid", ssid) end diff --git a/src/rest/api/api_printer.lua b/src/rest/api/api_printer.lua index 05c79d3..0b998d1 100644 --- a/src/rest/api/api_printer.lua +++ b/src/rest/api/api_printer.lua @@ -244,7 +244,7 @@ function M.heatup_POST(request, response) local argId,devpath,ultipath = getPrinterDataOrFail(request, response) if argId == nil then return end - local gcode = settings.get('printer.autoWarmUpCommand').."\n"; + local gcode = settings.get('printer.autoWarmUpCommand') .. "\n" local rv,msg = sendGcode(ultipath, gcode) if rv then @@ -257,7 +257,6 @@ function M.heatup_POST(request, response) end end ---UNTESTED --requires id(int) function M.stop_POST(request, response) local argId,devpath,ultipath = getPrinterDataOrFail(request, response) @@ -280,9 +279,9 @@ end --accepts: last(bool) (chunks will be concatenated and only when this argument is true will printing be started) function M.print_POST(request, response) local argId,devpath,ultipath = getPrinterDataOrFail(request, response) - local gtFile = ultipath .. '/' .. GCODE_TMP_FILE - if argId == nil then return end + + local gtFile = ultipath .. '/' .. GCODE_TMP_FILE local argGcode = request:get("gcode") local argIsFirst = utils.toboolean(request:get("first"))