Asynchronous Lua scripts

Asynchronous Lua scripts#

myGPIOd reads on startup the folder defined by lua_async_dir. Each file with the extension .lua is loaded and registered as Lua file. This files can be called with the lua_async action.

Note

These Lua scripts are executed in a new thread and therefore do not have access to data structures from the main thread. Use this type of scripts for longer running actions.

Custom lua functions#

myGPIOd registers custom lua functions to provide access to the actions. The functions return true on success, else false as first value.

Lua function

Description

local rc, resp_header, resp_body = http({method}, {uri}, {content-type}, {postdata})

Submits a HTTP request and waits for the response. Set content-type and postdata to nil if no body should be sent. Valid HTTP methods are: DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT

Example lua file#

local rc, resp_header, resp_body = http("GET", "http://test.lan/", nil, nil)
print(resp_body)