app.config={}

file.open('config.json')
local json=file.read()
local jsonder=sjson.decoder()
app.global.readFile('config.json',function(str)
    jsonder:write(str)
end)
json=jsonder:result()

local tag =nil
for k,v in pairs(json) do
    if(k=='devid' and v=='')then
        tag=true
        v=tostring(node.chipid())..tostring(math.random())
    end
    app.config[k]=v
end

if(tag==true)then
    app.global.update(app.config)
end

local heart=0
tmr.create():alarm(app.config.interval, tmr.ALARM_AUTO, function ()
    for i = 1, #app.intervalFun do  
        app.intervalFun[i](heart)  
        heart=1+heart
    end  
end)