25 lines
548 B
Lua
25 lines
548 B
Lua
local _C = {
|
|
TAG = "【4G网络】",
|
|
READY = false
|
|
}
|
|
|
|
sys.subscribe("IP_READY", function()
|
|
_C.READY = true
|
|
end)
|
|
|
|
function _C.init(v)
|
|
if _C.READY then
|
|
return 0, 0
|
|
end
|
|
local start_time = os.clock()
|
|
while not (_C.READY or ((os.clock() - start_time) * 100 > v)) do
|
|
if not _C.READY then
|
|
sys.wait(1000)
|
|
log.info(COSO, _C.TAG, "联网中:", (os.clock() - start_time) * 100, "超时:", v)
|
|
end
|
|
end
|
|
return _C.READY and 0 or 3, (os.clock() - start_time) * 100
|
|
end
|
|
|
|
return _C
|