-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
34 lines (28 loc) · 844 Bytes
/
init.lua
File metadata and controls
34 lines (28 loc) · 844 Bytes
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
require "common"
wifi.setmode(wifi.STATION)
print('MAC: ',wifi.sta.getmac())
print('chip: ',node.chipid())
print('heap: ',node.heap())
wifi_ssid = param_get("wifi_ssid")
wifi_pass = param_get("wifi_pass")
if (wifi_ssid == nil or wifi_pass == nil) then
print("WiFi credentials are missing... aborting")
do return end
end
station_cfg = {}
station_cfg.ssid = wifi_ssid
station_cfg.pwd = wifi_pass
station_cfg.save = false
wifi.sta.config(station_cfg)
wifi.sta.connect()
tmr.alarm(1, 1000, 1, function()
if wifi.sta.getip() == nil then
print("IP unavaiable, Waiting...")
else
tmr.stop(1)
print("ESP8266 mode is: " .. wifi.getmode())
print("The module MAC address is: " .. wifi.ap.getmac())
print("Config done, IP is " .. wifi.sta.getip())
dofile("main.lua")
end
end)