2012-09-26 18:27:10 +02:00
|
|
|
#!/usr/bin/env lua
|
|
|
|
|
|
|
|
require "ubus"
|
|
|
|
require "uloop"
|
|
|
|
|
|
|
|
uloop.init()
|
|
|
|
|
|
|
|
local conn = ubus.connect()
|
|
|
|
if not conn then
|
|
|
|
error("Failed to connect to ubus")
|
|
|
|
end
|
|
|
|
|
|
|
|
local my_method = {
|
|
|
|
broken = {
|
|
|
|
hello = 1,
|
|
|
|
hello1 = {
|
|
|
|
function(req)
|
|
|
|
end, {id = "fail" }
|
|
|
|
},
|
|
|
|
},
|
|
|
|
test = {
|
|
|
|
hello = {
|
2012-09-29 01:37:37 +02:00
|
|
|
function(req, msg)
|
2012-09-26 18:27:10 +02:00
|
|
|
conn:reply(req, {message="foo"});
|
|
|
|
print("Call to function 'hello'")
|
2012-09-29 01:37:37 +02:00
|
|
|
for k, v in pairs(msg) do
|
|
|
|
print("key=" .. k .. " value=" .. tostring(v))
|
|
|
|
end
|
2012-09-26 18:27:10 +02:00
|
|
|
end, {id = ubus.INT32, msg = ubus.STRING }
|
|
|
|
},
|
|
|
|
hello1 = {
|
|
|
|
function(req)
|
|
|
|
conn:reply(req, {message="foo1"});
|
|
|
|
conn:reply(req, {message="foo2"});
|
|
|
|
print("Call to function 'hello1'")
|
|
|
|
end, {id = ubus.INT32, msg = ubus.STRING }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
conn:add(my_method)
|
2013-11-07 13:51:11 +01:00
|
|
|
|
|
|
|
local my_event = {
|
|
|
|
test = function(msg)
|
|
|
|
print("Call to test event")
|
|
|
|
for k, v in pairs(msg) do
|
|
|
|
print("key=" .. k .. " value=" .. tostring(v))
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
|
|
|
conn:listen(my_event)
|
|
|
|
|
2012-09-26 18:27:10 +02:00
|
|
|
uloop.run()
|