Browse Source

add save version and ip msg

master
DESKTOP-B25GA9E\W35 1 year ago
parent
commit
2cdd93340a
  1. 8
      EasySave.lua
  2. 29
      WifiMgr.lua

8
EasySave.lua

@ -12,12 +12,12 @@ end @@ -12,12 +12,12 @@ end
--Save data to config files
function SaveData(key,value)
file.open("Config.lua", "w+")
file.open("Config.lua", "w+");
Config_Table[key] = value;
local tableStr = TableToStr(Config_Table);
file.write(tableStr);
file.close()
file.close();
--print(key.."-"..value.."has been Saved");
end
function TableToStr(table)
@ -29,7 +29,7 @@ function TableToStr(table) @@ -29,7 +29,7 @@ function TableToStr(table)
end
stringData = stringData:sub(1, #stringData - 2) .. "\n}\n"
stringData = "Config_Table = "..stringData;
print(stringData)
--print(stringData)
return stringData
end

29
WifiMgr.lua

@ -24,10 +24,9 @@ function ManualLink(ssid,passwd) @@ -24,10 +24,9 @@ function ManualLink(ssid,passwd)
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!");
SetIPFromFile();
end
PageMainScene(ssid,wifi.sta.getip(),"V1.0");
PageMainScene(ssid,wifi.sta.getip(),Config_Table["Version"]);
local lightArr = {[1]=false,[2]=false,[3]=false,[4]=false}
PageLight(lightArr)
--Service Open
@ -70,3 +69,27 @@ function SetIP(ipAddress,netmask,gateway) @@ -70,3 +69,27 @@ function SetIP(ipAddress,netmask,gateway)
wifi.sta.setip(IpCfg)
end
--SetIP("192.168.1.115","255.255.255.0","192.168.1.1")
function SaveIP(ipAddress,netmask,gateway)
SaveData("IpAddress",ipAddress);
SaveData("Netmask",netmask);
SaveData("Gateway",gateway);
end
function SetSoftVersion(version)
SaveData("Version",version);
end
function SetIPFromFile()
if Config_Table["IpAddress"]~=nil and Config_Table["Netmask"]~=nil and Config_Table["Gateway"]~=nil then
IpCfg = {
ip = Config_Table["IpAddress"],
netmask = Config_Table["Netmask"],
gateway = Config_Table["Gateway"]
}
wifi.sta.setip(IpCfg);
else
SetIP("192.168.1.210","255.255.255.0","192.168.1.1")
print("No Ip get,default to 192.168.1.210!");
end
end

Loading…
Cancel
Save