-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
39 lines (32 loc) · 1.03 KB
/
main.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
local function setglobal(k,v) rawset(_G, k, v) end
local function import(m, ...) local t = assert(loadfile(m .. ".lua"))(...) if t then setglobal(m, t) end end
setglobal("setglobal", setglobal)
setglobal("import", import)
node.LFS._initlfs()
wifi.setmode(wifi.STATION)
wifi.sta.config(CONFIG.wifi)
wifi.sta.autoconnect(1)
if CONFIG.ipconf then wifi.sta.setip(CONFIG.ipconf) end
--connect to WIFI as configured in init.lua
--wifi.sta.connect()
--wait until connected to WIFI
local wifiwaittmr = tmr.create()
wifiwaittmr:alarm(1000, tmr.ALARM_AUTO, function()
if wifi.sta.getip() == nil then
print("Connecting to AP...")
else
print('IP: ',wifi.sta.getip())
wifiwaittmr:stop(0)
import "telnet"
telnet.open()
import "loader"
end
end)
-- -- a global under the same name will be registered by safe.lua
-- local function errorLog(s)
-- print(s)
-- setglobal("LAST_ERROR", s)
-- return s
-- end
-- -- load the rest, safely
-- xpcall(function() import "loader" end, errorLog)