Hi,
I want to perform an XHR.Poll to send out API calls to an external device (with curl) I am however having difficulties in passing the variable parameters
XHR.poll(2, "/cgi-bin/luci/admin/network/modems/callrest", {"host":"0.0.0.1","query":"state"}, function (x, mArray) { ... <do some processing> });
In my controller lua file I have
entry({"admin", "network", "modems", "callrest"}, call("callmodemrest")).leaf = true
...
function callmodemrest(args)
local ut = require "luci.util"
local target= "https://" .. args[1].. "/" .. args[2]
local mArray = luci.json.decode(ut.trim(ut.trim(sys.exec("curl -k -u adm:pass " .. target))))
luci.http.prepare_content("application/json")
luci.http.write_json(mArray)
end
The problem I am having is to pass the query parameters between the XHR.poll and the lua entry. I can set them manually like
...
entry({"admin", "network", "modems", "callrest"}, call("callmodemrest", {"10.0.0.1","system/resource"})).leaf = true
...
which works fine, but hw to pass the parameters from XHR Poll
Thank you fro any pointers
Cheers
Michael