-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.lua
49 lines (46 loc) · 1.14 KB
/
logger.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
-- write file to log
function log(temp)
print("Log: "..temp)
file.open("log", 'a+')
file.writeline(temp)
file.close()
counter()
end
-- counter
function counter()
local threshold = 4
dofile("counter.lua")
print("Loading counter "..count)
local transmission = ""
if count > threshold then
print("Transmit")
file.open("log", 'r')
repeat _line = file.readline()
if (_line~=nil) then
transmission = transmission .. "temp[]="..(string.sub(_line,1,-2)) .. "&"
end
until _line==nil
file.close()
count = 0
--start wifi
dofile("wifi.lua")
dofile("transmit.lua")
tmr.alarm(1, 1000, 8, function()
if (wifi.sta.getip()) ~= nil then
tmr.stop(1)
transmit(transmission)
file.remove("log")
writeCounter()
end
end)
else
count = count + 1
writeCounter()
end
end
function writeCounter()
file.remove("counter.lua")
file.open("counter.lua", 'w+')
file.writeline("count = "..count)
file.close()
end