基于NodeMcu开发的ESP8266物联网LED灯控制设备,接入SSD1306作为配网以及服务显示功能,后续会增加更多功能
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.6 KiB

StationCfg = {}
IpCfg = {}
WifiSaved = {}
--Load Config.lua and get value from Config_Table
function AutoLink()
--get key from eus_params.lua
if Files["eus_params.lua"] then
WifiSaved = dofile("eus_params.lua");
else
AutoLinkByMobile();
PageAPNet();
return nil;
end
--SampleLink
ManualLink(WifiSaved.wifi_ssid,WifiSaved.wifi_password)
end
function ManualLink(ssid,passwd)
wifi.setmode(wifi.STATION)
StationCfg.ssid=ssid
StationCfg.pwd=passwd
StationCfg.save=true
wifi.sta.config(StationCfg)
wifi.sta.connect()
PageMainScene(ssid,wifi.sta.getip().."","V1.0");
local lightArr = {[1]=false,[2]=false,[3]=false,[4]=false}
PageLight(lightArr)
end
--mobile setting ap and passwd
function AutoLinkByMobile()
wifi.setmode(wifi.STATIONAP)
wifi.ap.config({ssid="DY-Light-Controller", auth=wifi.OPEN})
enduser_setup.manual(true)
enduser_setup.start(
"DY-Light-Controller",
function()
print("Connected to WiFi as:" .. wifi.sta.getip())
end,
function(err, str)
print("enduser_setup: Err #" .. err .. ": " .. str)
end
)
print("init endUserServer")
end
--GetAPList
-- function Listap(t)
-- for k,v in pairs(t) do
-- print(k.." : "..v)
-- end
-- end
-- wifi.sta.getap(Listap)
function SetIP(ipAddress,netmask,gateway)
IpCfg = {
ip = ipAddress,
netmask = netmask,
gateway = gateway
}
wifi.sta.setip(IpCfg)
end
--SetIP("192.168.1.115","255.255.255.0","192.168.1.1")