欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 請大師幫我看一下ESP8266網絡定時器的程序,哪里出現了問題。 [打印本頁]

作者: hdle    時間: 2019-3-22 04:56
標題: 請大師幫我看一下ESP8266網絡定時器的程序,哪里出現了問題。
現在以下的程序是用LUA進行編輯的,在以24小時的定時功能上出現了,由0:00-8:00的中斷(定時功能不起作用)。各位大俠們請為我指導!謝謝!

function exe_timer()
    --print("timer version=2");
    local fields,action,timer_str;
    local time = rtctime.epoch2cal(rtctime.get())
    local nowtime=string.format("%04d-%02d-%02d %02d:%02d",time["year"], time["mon"], time["day"],time["hour"] + time_zone,time["min"]);
    local repeatTime=0;
    local end_time=0;
    for i=1,#timer_array do
        fields  = string_split(timer_array[i],",")
        if(#fields>=5) then
            local timer_time=rtctime.epoch2cal(tonumber(fields[5])/1000);
            if(#fields>=6) then
                repeatTime=1;
                end_time=tonumber(fields[6])/1000;
            end

            timer_str=string.format("%04d-%02d-%02d",timer_time["year"], timer_time["mon"], timer_time["day"]).." "..fields[3];
            action=fields[4];

            if(repeatTime==1 and end_time>0) then
                nowtime=string.format("%02d:%02d",time["hour"] + time_zone,time["min"]);
                local ck_sec, ck_usec, ck_rate = rtctime.get()
                print("ck_end_time ="..ck_sec.. " end time="..end_time.." timer_str="..fields[3].." nowtime="..nowtime);
                if(fields[3]==nowtime and  ck_sec<=end_time) then
                    turn_by_index(tonumber(fields[2]),action);
                end
            else
                if(timer_str==nowtime) then
                    turn_by_index(tonumber(fields[2]),action);
                end
            end

        end
    end
end

function check_timer(ids)
    local find=0;
    local fields;
    local c_fields=string_split(ids,",");
    local del_list={}
    if(ids=="") then
        while #timer_array ~= 0 do rawset(timer_array, #timer_array, nil) end
        
        print("delete all timer,timer count="..#timer_array)
    else
        for i=1,#timer_array do
            fields  = string_split(timer_array[i],",")
            find=0
            for p =1,#c_fields do
                if(c_fields[p]==fields[1]) then
                    find=1
                    break;
                end
            end

            if(find==0) then
                del_list[#del_list+1]=fields[1];
            end
        end


        for i=1,#del_list do
            print("del timer,index="..del_list[i]);
            for j=1,#timer_array do
                fields  = string_split(timer_array[j],",")
                if(del_list[i]==fields[1]) then
                    table.remove(timer_array,j);
                    break
                end
            end
        end
        print("timer count="..#timer_array);
    end

    timer_change=1
end

function put_timer(timer_string)
    local ta;
    local fields;
    local new_timer_fields=string_split(timer_string,",")
    local find=0;
    for i=1,#timer_array do
        ta=timer_array[i];
        fields  = string_split(ta,",")
        if(ta==timer_string) then
            find=1;
            break;
        end
        if(fields[1]==new_timer_fields[1]) then
            timer_change=1;
            table.remove(timer_array,i);
            break;
        end
    end
    if(find==0) then
        timer_array[#timer_array+1]=timer_string
        timer_change=1
    end

end

function save_timer()
    local srcFile = file.open("timers.txt", "w")
    for i=1,#timer_array do
        srcFile:writeline(timer_array[i])
    end
    srcFile:close();
    srcFile=nil;
end

function read_timer()
    local ta
    local inpFile = file.open("timers.txt", "r")
    if(inpFile==nil) then
        return;
    end

    while true do
        ta = inpFile:readline()
        if(ta ==nil) then
            break;
        end
        print("timer:"..ta)
        ta=string.gsub(ta, "\n", "")
        timer_array[#timer_array+1]=ta
        break;
    end
    inpFile:close()
    inpFile=nil;
end

作者: hdle    時間: 2019-3-22 05:00
本帖最后由 hdle 于 2019-3-22 05:10 編輯

以下是被上面程序包含的文件

device_id=node.chipid();
wifConnected=0
cloud_server_domain=""
cloud_server_port=6088
cloud_socket=nil
cloud_connected=0;
global_domain="iot.0000.com"
global_domain_web_port=80
--global_domain="192.168.1.113"
--global_domain_web_port=8086
wechat_id="";
airkiss_id="";
version=0
reset_version=0;
WIFI_LED=1
WIFI_LED_STATUS=0;
WIFI_FLASH_COUNT=0;
timer_started=0;
reset_button_prcess_time=0
reset_finish=0;
sync_time=0
airkiss_info="";
timer_array={}
timer_change=0;
time_zone=8


作者: 503795163    時間: 2019-3-22 08:51
,用串口助手調試。
作者: 情淺    時間: 2019-3-22 09:55
程序重復了
作者: hdle    時間: 2019-3-22 19:55
情淺 發表于 2019-3-22 09:55
程序重復了

請指點下程序重復在哪? 謝謝




歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1