aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-10-15 19:44:08 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2015-10-15 19:44:08 +0200
commit446931c5f5d09a62e167c1754fbe17773eaae6a4 (patch)
tree2e08d6045a83a9957d721c3b3bcdf04bfee9a030
parent81a276ab7840d6f9c64da80fe5d3bad88fb99b83 (diff)
downloadesp-playground-446931c5f5d09a62e167c1754fbe17773eaae6a4.tar.gz
esp-playground-446931c5f5d09a62e167c1754fbe17773eaae6a4.tar.bz2
esp-playground-446931c5f5d09a62e167c1754fbe17773eaae6a4.tar.xz
esp-playground-446931c5f5d09a62e167c1754fbe17773eaae6a4.zip
wip
-rw-r--r--Makefile2
-rw-r--r--diller/main.lua23
2 files changed, 19 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index d33b461..0471eae 100644
--- a/Makefile
+++ b/Makefile
@@ -9,5 +9,5 @@ compile-%:
@$(MAKE) -j 8 $(patsubst %.lua,%.lc,$(wildcard $(patsubst compile-%,%,$@)/*.lua))
upload-%:
-# @$(MAKE) $(patsubst upload-%,compile-%,$@)
+ @$(MAKE) $(patsubst upload-%,compile-%,$@)
./upload.sh $(patsubst upload-%,%,$@)
diff --git a/diller/main.lua b/diller/main.lua
index f982f8c..234a84b 100644
--- a/diller/main.lua
+++ b/diller/main.lua
@@ -9,6 +9,8 @@ local P = {}
local inter = require('inter')
local mq = require('mq')
+local properties = {}
+
local function on_cmd(cmd, args)
if not cmd then
return
@@ -44,21 +46,32 @@ local function on_cmd(cmd, args)
if not id then
print("fail status=missing-id")
else
- local name_path = id.."/name"
- mq.subscribe(name_path, function() print('message on '..path) end)
+ property = properties[id]
+ local name_path = id.."/name"
local description_path = id.."/description"
- mq.subscribe(description_path, function() print('message on '..path) end)
+
+ if not property then
+ print("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)
+ end
if args.value then
local path = id.."/value"
mq.publish(path, args.value)
end
- if args.name then
+ if args.name and property.name ~= args.name then
+ print("publishing name")
mq.publish(name_path, args.name)
+ property.name = args.name
end
- if args.description then
+ if args.description and property.description ~= args.description then
+ print("publishing description")
mq.publish(description_path, args.description)
+ property.description = args.description
end
end
elseif cmd == "publish" then