add command line option for client

Signed-off-by: zhaojh329 <jianhuizhao329@gmail.com>
This commit is contained in:
zhaojh329
2017-06-08 12:59:04 +08:00
parent 77a058931e
commit 4c06d25196
3 changed files with 19 additions and 2 deletions
+3
View File
@@ -0,0 +1,3 @@
config base
option mqtt_hostname 'jianhuizhao.f3322.net'
option mqtt_port '8883'
Regular → Executable
+13 -1
View File
@@ -5,9 +5,21 @@ START=99
BIN=/usr/sbin/xterminal_device
mqtt_hostname=
mqtt_port=
parse_conf() {
local cfg=$1
config_get mqtt_hostname "$cfg" "mqtt_hostname"
config_get mqtt_port "$cfg" "mqtt_port"
}
start_service() {
config_load xterminal
config_foreach parse_conf base
procd_open_instance
procd_set_param command $BIN br-lan
procd_set_param command $BIN br-lan "$mqtt_hostname:$mqtt_port"
procd_close_instance
}
+3 -1
View File
@@ -9,6 +9,8 @@ local loop = ev.Loop.default
local mgr = evmg.init()
local ifname = arg[1] or "eth0"
local server = arg[2] or "localhost:1883"
local devid = nil
local session = {}
@@ -91,7 +93,7 @@ end
print("devid:", devid)
mgr:connect("localhost:1883", ev_handle)
mgr:connect(server, ev_handle)
ev.Signal.new(function(loop, sig, revents)
loop:unloop()