基于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.

73 lines
1.8 KiB

1 year ago
StationCfg = {}
IpCfg = {}
1 year ago
WifiSaved = {}
1 year ago
1 year ago
--Load Config.lua and get value from Config_Table
1 year ago
function AutoLink()
1 year ago
--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)
1 year ago
wifi.setmode(wifi.STATION)
1 year ago
StationCfg.ssid=ssid
StationCfg.pwd=passwd
StationCfg.save=false
1 year ago
wifi.sta.config(StationCfg)
wifi.sta.connect()
if wifi.sta.getip() == nil then
SetIP("192.168.1.115","255.255.255.0","192.168.1.1")
print("No Ip get,default to 192.168.1.115!");
end
PageMainScene(ssid,wifi.sta.getip(),"V1.0");
1 year ago
local lightArr = {[1]=false,[2]=false,[3]=false,[4]=false}
PageLight(lightArr)
--Service Open
StartUDPService();
print(wifi.sta.status());
1 year ago
end
--mobile setting ap and passwd
function AutoLinkByMobile()
wifi.setmode(wifi.STATIONAP)
1 year ago
wifi.ap.config({ssid="DY-Light-Controller", auth=wifi.OPEN})
1 year ago
enduser_setup.manual(true)
enduser_setup.start(
1 year ago
"DY-Light-Controller",
1 year ago
function()
print("Connected to WiFi!")
1 year ago
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")