http_get_custom
This is an old revision of the document!
HTTP request implemention using custom protocol
get_example = [[ GET /api/register-values HTTP/1.1 Host: 127.0.0.1 X-WH-APIKEY:5D78CB6F0B0ACC526F2CB8BF65B471A2E594D309 X-WH-CONNECTIONS: 1 Accept: application/json Content-Type: application/json ]] response = "no response" function createDevices () addDevice({name = "S", shift = 0, base = 10, xtraFields = {}}) end function onScanStart () -- no actions on scan start end function readRegister (reg, device, unitId) return response end function writeRegister (reg, device, unitId, newValue) sendString(get_example) local s = read_string() if (not s) or (#s == 0) then return false else response = s -- copy response to global return true end end function read_string() local str = {} repeat local char_ = readString(1) if char_ then -- DEBUG("Read char = " .. char_) table.insert(str, char_) end until not char_ local response = table.concat(str) DEBUG("read_string going to return " .. response) return response end
http_get_custom.1626174419.txt.gz ยท Last modified: 2021/07/13 11:06 by emozolyak