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.
72 lines
1.8 KiB
72 lines
1.8 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=false |
|
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"); |
|
local lightArr = {[1]=false,[2]=false,[3]=false,[4]=false} |
|
PageLight(lightArr) |
|
--Service Open |
|
StartUDPService(); |
|
print(wifi.sta.status()); |
|
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!") |
|
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")
|
|
|