aboutsummaryrefslogtreecommitdiff
path: root/diller/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'diller/main.lua')
-rw-r--r--diller/main.lua31
1 files changed, 15 insertions, 16 deletions
diff --git a/diller/main.lua b/diller/main.lua
index dc1032d..3450bec 100644
--- a/diller/main.lua
+++ b/diller/main.lua
@@ -4,6 +4,10 @@ function panic(reason)
node.restart()
end
+info = function(msg)
+ print("info "..msg)
+end
+
local P = {}
local inter = require('inter')
@@ -46,11 +50,11 @@ local function configure_wlan()
local wlan_password = read_cfg("wlan-password", false)
if not wlan_ssid or not wlan_password then
- print("Missing SSID and/or password configuration, use 'wlan' to configure")
+ info("Missing SSID and/or password configuration, use 'wlan' to configure")
return
end
- print("Connecting to SSID: "..wlan_ssid)
+ info("Connecting to SSID: "..wlan_ssid)
wifi.setmode(wifi.STATION)
wifi.sta.config(wlan_ssid, wlan_password)
end
@@ -60,9 +64,9 @@ local function on_cmd(cmd, args)
return
end
- print("on_cmd: '"..cmd.."', #args="..tostring(table.getn(args)))
+ info("on_cmd: '"..cmd.."', #args="..tostring(table.getn(args)))
for k, v in pairs(args) do
- print(k.."="..tostring(v))
+ info(k.."="..tostring(v))
end
if cmd == "reset" then
@@ -104,23 +108,23 @@ local function on_cmd(cmd, args)
local description_path = "property/"..id.."/description"
if not property then
- print("new property: "..id)
+ info("new property: "..id)
property = {}
properties[id] = property
- mq.subscribe(name_path, function() print('message on '..path) end)
- mq.subscribe(description_path, function() print('message on '..path) end)
+ mq.subscribe(name_path, function() info('message on '..path) end)
+ mq.subscribe(description_path, function() info('message on '..path) end)
end
if args.value then
mq.publish(value_path, args.value)
end
if args.name and property.name ~= args.name then
- print("publishing name")
+ info("publishing name")
mq.publish(name_path, args.name)
property.name = args.name
end
if args.description and property.description ~= args.description then
- print("publishing description")
+ info("publishing description")
mq.publish(description_path, args.description)
property.description = args.description
end
@@ -139,13 +143,8 @@ local function on_cmd(cmd, args)
end
local function print_status()
- print("System Status")
- print("Uptime : "..tmr.time())
- print("Heap left: "..node.heap())
ip, nm, gw = wifi.sta.getip()
- print("IP : "..tostring(ip))
- print("Netmask : "..tostring(nm))
- print("Gateway : "..tostring(gw))
+ print("status uptime="..tmr.time().." heap-left="..node.heap().." ip="..tostring(ip).." netmask="..tostring(nm).." gateway="..tostring(gw))
end
-- uart.setup(id, baud, databits, parity, stopbits, echo)
@@ -183,7 +182,7 @@ function P.main()
-- payload = payload.."}"
-- P.publish("firmware", payload)
- print("init done")
+ info("init done")
end
return P