diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-10-04 13:13:58 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-10-04 13:13:58 +0200 |
commit | dcba99769089f3ebccf839f4be6c605da52e64d7 (patch) | |
tree | 6a12e37873919c6486b326b3c5293701937fbb34 /mqtt-bridge/inter.lua | |
parent | 9778f5d43ffca26e3def45f21a163c1a83feb7be (diff) | |
download | esp-playground-dcba99769089f3ebccf839f4be6c605da52e64d7.tar.gz esp-playground-dcba99769089f3ebccf839f4be6c605da52e64d7.tar.bz2 esp-playground-dcba99769089f3ebccf839f4be6c605da52e64d7.tar.xz esp-playground-dcba99769089f3ebccf839f4be6c605da52e64d7.zip |
o More idiomatic Lua code.
Diffstat (limited to 'mqtt-bridge/inter.lua')
-rw-r--r-- | mqtt-bridge/inter.lua | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/mqtt-bridge/inter.lua b/mqtt-bridge/inter.lua index 3b117a9..2c6a5ad 100644 --- a/mqtt-bridge/inter.lua +++ b/mqtt-bridge/inter.lua @@ -1,4 +1,6 @@ -function inter_parse(line) +local P = {} + +function P.parse(line) -- print("inter_parse: line="..line) line = string.sub(line, 1, string.find(line, "\r")) @@ -51,7 +53,7 @@ local cb function inter_on_line(line) print("line:"..line) - local cmd, args = inter_parse(line) + local cmd, args = P.parse(line) if not cmd then return end @@ -61,11 +63,10 @@ function inter_on_line(line) end end -function inter_init(callback) - -- uart.setup(id, baud, databits, parity, stopbits, echo) - -- uart.setup(0, 115200, 8, 0, 1, 0) - -- uart.setup(0, 9600, 8, 0, 1, 0) +function P.init(callback) cb = callback uart.on("data", "\r", inter_on_line, 0) end + +return P |