local config = self._conf or {}
--[[
config.devs = config.devs or {
{ unit = 1, name = 'bms01', sn = 'xxx-xx-1', tpl = 'bms' },
{ unit = 2, name = 'bms02', sn = 'xxx-xx-2', tpl = 'bms2' }
}
]]--
--- 获取云配置
if not config.devs or config.cnf then
if not config.cnf then
config = 'CNF000000002.1' -- loading cloud configuration CNF000000002 version 1
else
config = config.cnf .. '.' .. config.ver
end
end
local helper = conf_helper:new(self._sys, config)
helper:fetch()
self._devs = {}
for _, v in ipairs(helper:devices()) do
-- initialize your devices
end
--- 获取配置
local conf = helper:config()
conf.channel_type = conf.channel_type or 'socket'
if conf.channel_type == 'socket' then
conf.opt = conf.opt or {
host = "127.0.0.1",
port = 1503,
nodelay = true
}
else
conf.opt = conf.opt or {
port = "/dev/ttymxc1",
baudrate = 115200
}
end
if conf.channel_type == 'socket' then
client = sm_client(socketchannel, conf.opt, modbus.apdu_tcp, 1)