test_client.lua 808 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env lua
  2. require "ubus"
  3. require "uloop"
  4. uloop.init()
  5. local conn = ubus.connect()
  6. if not conn then
  7. error("Failed to connect to ubusd")
  8. end
  9. local namespaces = conn:objects()
  10. for i, n in ipairs(namespaces) do
  11. print("namespace=" .. n)
  12. local signatures = conn:signatures(n)
  13. for p, s in pairs(signatures) do
  14. print("\tprocedure=" .. p)
  15. for k, v in pairs(s) do
  16. print("\t\tattribute=" .. k .. " type=" .. v)
  17. end
  18. end
  19. end
  20. local status = conn:call("test", "hello", { msg = "eth0" })
  21. for k, v in pairs(status) do
  22. print("key=" .. k .. " value=" .. tostring(v))
  23. end
  24. local status = {conn:call("test", "hello1", { msg = "eth0" })}
  25. for a = 1, #status do
  26. for k, v in pairs(status[a]) do
  27. print("key=" .. k .. " value=" .. tostring(v))
  28. end
  29. end
  30. conn:send("test", { foo = "bar"})
  31. uloop.run()