mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-12-22 11:03:48 +01:00
add check for control and clear gcode on print fetch start
This commit is contained in:
parent
82d4179bc3
commit
2f91065ff7
@ -189,10 +189,37 @@ function M.fetch_POST(request, response)
|
|||||||
local printer,msg = printerUtils.createPrinterOrFail(argId, response)
|
local printer,msg = printerUtils.createPrinterOrFail(argId, response)
|
||||||
if not printer or not printer:hasSocket() then return end
|
if not printer or not printer:hasSocket() then return end
|
||||||
|
|
||||||
|
local controllerIP = accessManager.getController()
|
||||||
|
local hasControl = false
|
||||||
|
if controllerIP == "" then
|
||||||
|
accessManager.setController(request.remoteAddress)
|
||||||
|
hasControl = true
|
||||||
|
elseif controllerIP == request.remoteAddress then
|
||||||
|
hasControl = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if not hasControl then
|
||||||
|
response:setFail("No control access")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
log:verbose(MOD_ABBR, " clearing all gcode for " .. printer:getId())
|
||||||
|
response:addData('gcode_clear',true)
|
||||||
|
local rv,msg = printer:clearGcode()
|
||||||
|
|
||||||
|
if rv == false then
|
||||||
|
response:addData('status', msg)
|
||||||
|
response:setFail("could not clear gcode (" .. msg .. ")")
|
||||||
|
elseif rv == nil then
|
||||||
|
response:setError(msg)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local socket = printer:getId()
|
local socket = printer:getId()
|
||||||
local remote = settings.get('gcode_server')
|
local remote = settings.get('gcode_server')
|
||||||
local id = request:get("id")
|
local id = request:get("id")
|
||||||
io.popen("print-fetch.lua " .. socket .. " " .. remote .. " " .. id)
|
io.popen("print-fetch " .. socket .. " " .. remote .. " " .. id)
|
||||||
response:setSuccess()
|
response:setSuccess()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user