202 断线重连机制请教

情况这样的,之前常规时候,测试断线重连,比如我没两分钟重新发现tcp连接一次,失败的话是如下log

[2019-12-20 13:04:42,306.306]: host trace [I]-[ril.proatc]0, CONNECT FAIL

[2019-12-20 13:04:42,309.309]: host trace [I]-[---------------------- 网络注册已成功 ----------------------]

[2019-12-20 13:04:42,348.348]: host trace [I]-[ril.proatc]

[2019-12-20 13:04:42,349.349]: host trace [I]-[ril.proatc]STATE: IP PROCESSING

[2019-12-20 13:04:42,351.351]: host trace [I]-[link.STATE]IP STATUSIP PROCESSING

[2019-12-20 13:04:42,354.354]: host trace [I]-[ril.proatc]

[2019-12-20 13:04:42,355.355]: host trace [I]-[ril.proatc]7, CONNECT FAIL

[2019-12-20 13:04:42,368.368]: host trace [I]-[---------------------- 网络注册已成功 ----------------------]

[2019-12-20 13:04:42,408.408]: host trace [I]-[ril.proatc]

[2019-12-20 13:04:42,411.411]: host trace [I]-[ril.proatc]STATE: IP PROCESSING

[2019-12-20 13:04:42,414.414]: host trace [I]-[link.STATE]IP STATUSIP PROCESSING

[2019-12-20 13:04:42,417.417]: host trace [I]-[ril.proatc]

[2019-12-20 13:04:42,420.420]: host trace [I]-[ril.proatc]2, CONNECT FAIL

[2019-12-20 13:04:42,433.433]: host trace [I]-[---------------------- 网络注册已成功 ----------------------]


上面网络注册成功是订阅"IP_READY_IND"这个主题的,这样是否说明底层软件在我脚本发起链接的情况下会出发ip网络链路的检查?

sys.subscribe("IP_READY_IND"function()
    sys.timerStop(tid)
    log.info("---------------------- 网络注册已成功 ----------------------")
end)
但是其中挂机时间有天中午一直没有重连成功,也没有发出"IP_READY_IND"的订阅消息,是在发送失败后产生的不是人为断网重连测试 log 如下
但是其中挂机时间有天中午一直没有重连成功,也没有发出"IP_READY_IND"的订阅消息,是在发送失败后产生的不是人为断网重连测试

log 如下

[2019-12-20 11:02:24,328.328]: host trace [I]-[ril.proatc]4, SEND FAIL
[2019-12-20 11:02:24,888.888]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:02:25,144.144]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:25,380.380]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:02:25,642.642]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:25,911.911]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:26,188.188]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:02:26,438.438]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:02:26,683.683]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:26,937.937]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:02:27,204.204]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:27,486.486]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:27,742.742]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:02:28,026.026]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:02:28,282.282]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:28,522.522]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:02:28,756.756]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:28,997.997]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:29,269.269]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:02:30,246.246]: host trace [I]-[ril.proatc]+CENG:0,"0084,20,99,460,00,60,35816,12,05,22500,00"
[2019-12-20 11:02:30,470.470]: host trace [I]-[ril.proatc]+CENG:1,"81,14,460,0,5,15816,22500"
[2019-12-20 11:02:30,709.709]: host trace [I]-[ril.proatc]+CENG:2,"86,10,460,0,63,15246,22500"
[2019-12-20 11:02:30,950.950]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:31,200.200]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:31,476.476]: host trace [I]-[net.rsp]AT+CENG?trueOKnil
[2019-12-20 11:02:31,871.871]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:02:32,309.309]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:32,638.638]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:02:32,918.918]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:33,246.246]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:33,496.496]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:02:34,000.000]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:02:34,269.269]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:02:34,549.549]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:34,831.831]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:02:35,107.107]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:35,375.375]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:02:35,661.661]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:35,941.941]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:36,223.223]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:02:36,497.497]: host trace [I]-[ril.sendat]AT+CIPCLOSE=7
[2019-12-20 11:02:36,809.809]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:37,112.112]: host trace [I]-[ril.proatc]ERROR
[2019-12-20 11:02:37,447.447]: host trace [I]-[ril.sendat]AT+CIPSTART=5,"TCP","118.24.153.136",8989
[2019-12-20 11:02:37,765.765]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:38,039.039]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:38,325.325]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:02:38,605.605]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:38,900.900]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:02:39,171.171]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:39,457.457]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:39,776.776]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:02:40,091.091]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:02:40,368.368]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:40,630.630]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:02:40,944.944]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:41,233.233]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:41,513.513]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:02:41,819.819]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:02:42,138.138]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:42,426.426]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:02:42,713.713]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:42,977.977]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:43,250.250]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:02:43,503.503]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:02:43,753.753]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:43,986.986]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:02:44,219.219]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:44,459.459]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:44,697.697]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:02:44,930.930]: host trace [I]-[ril.sendat]AT+CIPCLOSE=2
[2019-12-20 11:02:45,157.157]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:45,388.388]: host trace [I]-[ril.proatc]ERROR
[2019-12-20 11:02:45,632.632]: host trace [I]-[ril.sendat]AT+CIPSTART=3,"TCP","118.24.153.136",8989
[2019-12-20 11:02:45,865.865]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:46,130.130]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:46,381.381]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:02:46,618.618]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:46,867.867]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:02:47,102.102]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:47,365.365]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:47,598.598]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:02:47,895.895]: host trace [I]-[ril.sendat]AT+CENG?
[2019-12-20 11:02:48,155.155]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:48,434.434]: host trace [I]-[ril.proatc]+CENG:1,1
[2019-12-20 11:02:48,668.668]: host trace [I]-[ril.proatc]+CENG:0,"0084,20,99,460,00,60,35816,12,05,22500,00"
[2019-12-20 11:02:48,953.953]: host trace [I]-[ril.proatc]+CENG:1,"81,14,460,0,5,15816,22500"
[2019-12-20 11:02:49,223.223]: host trace [I]-[ril.proatc]+CENG:2,"86,10,460,0,63,15246,22500"
[2019-12-20 11:02:49,515.515]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:49,769.769]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:50,059.059]: host trace [I]-[net.rsp]AT+CENG?trueOKnil
[2019-12-20 11:02:50,342.342]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:02:50,575.575]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:50,829.829]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:02:51,105.105]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:51,351.351]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:51,664.664]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:02:51,927.927]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:02:52,450.450]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:02:52,714.714]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:52,960.960]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:53,201.201]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:02:53,438.438]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:02:53,680.680]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:53,946.946]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:02:54,206.206]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:54,457.457]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:54,676.676]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:02:54,915.915]: host trace [I]-[ril.sendat]AT+CIPCLOSE=0
[2019-12-20 11:02:55,157.157]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:55,392.392]: host trace [I]-[ril.proatc]ERROR
[2019-12-20 11:02:55,640.640]: host trace [I]-[ril.sendat]AT+CIPSTART=7,"TCP","118.24.153.136",8989
[2019-12-20 11:02:55,891.891]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:56,141.141]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:56,395.395]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:02:56,630.630]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:56,861.861]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:02:57,091.091]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:57,313.313]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:57,549.549]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:02:57,778.778]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:02:58,033.033]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:58,276.276]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:02:58,513.513]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:58,752.752]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:02:59,013.013]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:02:59,255.255]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:02:59,487.487]: host trace [I]-[ril.proatc]
[2019-12-20 11:02:59,720.720]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:02:59,956.956]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:00,184.184]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:03:00,423.423]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:03:00,690.690]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:03:00,970.970]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:01,198.198]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:03:01,434.434]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:01,661.661]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:03:01,891.891]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:03:02,141.141]: host trace [I]-[ril.sendat]AT+CIPCLOSE=1
[2019-12-20 11:03:02,365.365]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:02,598.598]: host trace [I]-[ril.proatc]ERROR
[2019-12-20 11:03:03,081.081]: host trace [W]-[socket: response on nil socket]AT+CIPCLOSE=1ERROR
[2019-12-20 11:03:03,315.315]: host trace [I]-[ril.sendat]AT+CIPSTART=2,"TCP","118.24.153.136",8989
[2019-12-20 11:03:03,556.556]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:03,786.786]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:03:04,028.028]: host trace [I]-[ril.sendat]AT+CENG?
[2019-12-20 11:03:04,266.266]: host trace [I]-[timer_cnt_1]74
[2019-12-20 11:03:04,500.500]: host trace [I]-[delay_cnt_1]1
[2019-12-20 11:03:04,730.730]: host trace [I]-[timer_cnt_2]74
[2019-12-20 11:03:04,971.971]: host trace [I]-[delay_cnt_2]1
[2019-12-20 11:03:05,203.203]: host trace [I]-[timer_cnt_3]74
[2019-12-20 11:03:05,427.427]: host trace [I]-[delay_cnt_3]1
[2019-12-20 11:03:05,654.654]: host trace [I]-[timer_cnt_4]74
[2019-12-20 11:03:05,877.877]: host trace [I]-[delay_cnt_4]1
[2019-12-20 11:03:06,111.111]: host trace [I]-[timer_cnt_5]74
[2019-12-20 11:03:06,345.345]: host trace [I]-[delay_cnt_5]1
[2019-12-20 11:03:06,592.592]: host trace [I]-[timer_cnt_6]74
[2019-12-20 11:03:06,821.821]: host trace [I]-[delay_cnt_6]1
[2019-12-20 11:03:07,052.052]: host trace [I]-[random_data: ]
[2019-12-20 11:03:07,282.282]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:07,509.509]: host trace [I]-[ril.proatc]+CENG:1,1
[2019-12-20 11:03:07,755.755]: host trace [I]-[ril.proatc]+CENG:0,"0084,20,99,460,00,60,35816,12,05,22500,00"
[2019-12-20 11:03:07,990.990]: host trace [I]-[ril.proatc]+CENG:1,"81,14,460,0,5,15816,22500"
[2019-12-20 11:03:08,276.276]: host trace [I]-[ril.proatc]+CENG:2,"86,10,460,0,63,15246,22500"
[2019-12-20 11:03:08,510.510]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:08,742.742]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:03:08,993.993]: host trace [I]-[net.rsp]AT+CENG?trueOKnil
[2019-12-20 11:03:09,246.246]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:03:09,479.479]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:09,711.711]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:03:09,944.944]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:10,181.181]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:03:10,404.404]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:03:10,644.644]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:03:10,905.905]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:11,180.180]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:03:11,430.430]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:11,688.688]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:03:11,927.927]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:03:12,401.401]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:12,690.690]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:03:12,953.953]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:13,206.206]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:03:13,450.450]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:03:13,693.693]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:03:13,937.937]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:14,187.187]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:03:14,414.414]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:14,641.641]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:03:14,874.874]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:03:15,115.115]: host trace [I]-[ril.sendat]AT+CSQ
[2019-12-20 11:03:15,362.362]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:15,637.637]: host trace [I]-[ril.proatc]+CSQ: 19,0
[2019-12-20 11:03:15,875.875]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:16,098.098]: host trace [I]-[ril.proatc]OK
[2019-12-20 11:03:16,338.338]: host trace [I]-[net.rsp]AT+CSQtrueOK+CSQ: 19,0
[2019-12-20 11:03:16,575.575]: host trace [I]-[ril.sendat]AT+CIPCLOSE=6
[2019-12-20 11:03:16,812.812]: host trace [I]-[ril.proatc]
[2019-12-20 11:03:17,051.051]: host trace [I]-[ril.proatc]ERROR
[2019-12-20 11:03:17,512.512]: host trace [W]-[socket: response on nil socket]AT+CIPCLOSE=6ERROR

其中 response on nil socket 是怎么产生的,代码参考的是irtu的一个socketdemo
local function tcpTask(cidconfig)
    -- cid 通道编号     prot-tcp--udp选择   timeout 超时时间没有定义这是120
    cidtimeout = tonumber(cid) or 1150
    -- 心跳字节设定没有这是0x00
    --local ping = make_heart_packet(cid)
    -- local login = make_base_packet(cid)
    -- local state_packet = make_state_packet(cid)
    local resoult
    while true do
        local idx = 0
        if not socket.isReady() and not sys.waitUntil("IP_READY_IND"rstTimthen restart_sys("网络初始化失败!"end
        local c = socket.tcp()
        while not c:connect(config.ipconfig.portdo sys.wait(120000end
 
        if device_config[cid].restart_flag == true then
            -- 需要发送
            resoult = c:send(make_base_packet(cid))
            log_flag[cid] = true
            resoult = c:send(make_state_packet(cid))
            device_config[cid].next_state_time = os.time() + start_report_time
        end
        if c:send(make_heart_packet(cid)) then
            delay_cnt[cid] = 12
          
            -- 发出注册成功标志位,
            --sys.publish("LINK_OK_" .. cid)
            while true do
                datalink = true
                local resultdataparam = c:recv(timeout * 1000"NET_SENT_RDY_" .. cid)
                if result then
                    -- 这里执行用户自定义的指令
                    -- 收到数据
                    log.info("device"cid)
                    log.info("recvdata"data)
                    --开启允许发送数据
                    -- alsend_flag[cid]=true
                    sys.timerStop(timer_id[cid])
                    sys.publish("NET_RECV_WAIT_" .. cidciddata)
                elseif data == ("NET_SENT_RDY_" .. cidthen
                    -- 等待发送数据
                    -- if alsend_flag[cid] then
                    --     alsend_flag[cid]=false
                    log.info("device"cid)
                    -- log.info("senddata", param)
                    if not c:send(paramthen
                        -- 发送失败
                        break
                    end
                -- 发送成功
         
                elseif data == "timeout" then
                    -- 其他地方有定时发包函数,没有使用固定心跳包
                    else
                    break
                end
            end
        end
        c:close()
        datalink = false
        sys.wait(5000)
    end
end
---------------------------------------------------------- 参数配置,任务转发,线程守护主进程----------------------------------------------------------
function connect()
    local flyTag = false

    -- 等待网络ok
    if not socket.isReady() and not sys.waitUntil("IP_READY_IND"rstTimthen restart_sys("网络初始化失败!"end
    -- 等待系统启动后的数据更新成功,2min
    -- sys.waitUntil("DTU_PARAM_READY", 120000)
    sys.waitUntil("NTP_SUCCEED"60000)
    -- 自动创建透传任务并填入参数
    for i = 161 do
        log.warn("----------------------- TCP/UDP is start! --------------------------------------")
        sys.taskInit(tcpTaskidevice_config[i])
    end

    -- 守护进程
    while true do
        -- 这里是网络正常,但是链接服务器失败重启    14400000->4h
        if datalink then sys.timerStart(restart_sys14400000"Server connection failed"end
        sys.wait(1000)
    end
end
net.switchFly(false)
-- NTP同步失败强制重启
local tid = sys.timerStart(function()
    net.switchFly(true)
    sys.timerStart(net.switchFly5000false)
endflyTim)
sys.subscribe("IP_READY_IND"function()
    sys.timerStop(tid)
    log.info("---------------------- 网络注册已成功 ----------------------")
end)
sys.taskInit(connect)
请先 登录 后评论

1 个回答

技术销售Delectate
擅长:IT

请检查卡是否欠费。

请先 登录 后评论