forked from devyte/nodemcu-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
38 lines (30 loc) · 930 Bytes
/
init.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
--STEP0: print some info
print('chip: ',node.chipid())
print('heap: ',node.heap())
--STEP1: init hw settings
--gpio.mode(6, gpio.OUTPUT, gpio.PULLUP)
--gpio.mode(7, gpio.OUTPUT, gpio.PULLUP)
--gpio.mode(8, gpio.OUTPUT, gpio.PULLUP)
--gpio.write(6, 0)
--gpio.write(7, 0)
--gpio.write(8, 0)
--STEP2: compile all .lua files to .lc files
local compilelua = "compile.lua"
if file.exists(compilelua) then
dofile(compilelua)(compilelua)
end
compilelua = nil
dofile("compile.lc")()
--STEP3: load tools
dofile("tools.lc")
--STEP4: move files to subdirs and unload tools
tools.mv2http()
tools = nil
--STEP5: handle wifi config
dofile("wifi.lc")
--STEP6: start the TCP server in port 80, if an ip is available
tcpsrv = dofile("tcpserver.lc")(80, {httpserver = true, luaserver = true})
--STEP7: start the tftp server for easy file upload
--tftpsrv = dofile("tftpd.lc")(69)
collectgarbage()
print('heap after init: ', node.heap())