C'est bon maintenant le setup wifi marche bien mais j'ai encore des problèmes de mémoire juste après avoir eu une adresse ip :-(
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
-- Scripts à charger après le boot pour démarrer le core system
|
||||
|
||||
print("\n boot.lua zf200105.2358 \n")
|
||||
print("\n boot.lua zf200106.1815 \n")
|
||||
|
||||
function boot()
|
||||
if zswitch ~= nill then
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
-- Scripts à charger après le boot pour démarrer son projet
|
||||
|
||||
print("\n boot2.lua zf200101.1240 \n")
|
||||
print("\n boot2.lua zf200106.1817 \n")
|
||||
|
||||
function boot2()
|
||||
print("boot2 starting...")
|
||||
second_chance=nil initz=nil boot=nil zLED=nil
|
||||
boot2_tmr=nil secrets_wifi=nil wifi_init=nil
|
||||
cli_ssid=nil cli_pwd=nil
|
||||
boot2_tmr1=nil wifi_init1=nil wifi_info=nil boot2_go=nil
|
||||
collectgarbage()
|
||||
second_chance=nil initz=nil boot=nil
|
||||
boot2_tmr=nil boot2_tmr1=nil boot2_go=nil
|
||||
print(node.heap()) collectgarbage() print(node.heap())
|
||||
|
||||
--f= "0_htu21d.lua" if file.exists(f) then dofile(f) end
|
||||
--f= "0_send_data.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Petit script pour afficher les infos actuel du WIFI
|
||||
print("\n wifi_info.lua zf191030.2017 \n")
|
||||
print("\n wifi_info.lua zf200106.1803 \n")
|
||||
|
||||
function wifi_info()
|
||||
local zmodewifi=wifi.getmode()
|
||||
@@ -39,6 +39,7 @@ function wifi_info()
|
||||
print("\tpassword:", ap_config.pwd)
|
||||
print("\tbssid:", wifi.ap.getmac())
|
||||
end
|
||||
wifi_info=nil
|
||||
end
|
||||
wifi_info()
|
||||
|
||||
|
||||
@@ -1,57 +1,69 @@
|
||||
-- Petit script pour initaliser la couche WIFI
|
||||
|
||||
function wifi_init()
|
||||
print("\n wifi_init.lua zf200105.2355 \n")
|
||||
-- charge les secrets pour le wifi
|
||||
f= "secrets_wifi.lua" if file.exists(f) then dofile(f) end
|
||||
f= "secrets_project.lua" if file.exists(f) then dofile(f) end
|
||||
print("\n wifi_init.lua zf200106.1846 \n")
|
||||
|
||||
wifi.setmode(wifi.STATIONAP,true)
|
||||
|
||||
wifi.sta.config{ssid=cli_ssid, pwd=cli_pwd, auto=true, save=true}
|
||||
wifi.sta.autoconnect(1) wifi.sta.connect()
|
||||
|
||||
if node_id == nil then node_id = "generic" end
|
||||
wifi.ap.config({ ssid = ap_ssid.."_"..node_id, pwd = ap_pwd, save=true })
|
||||
ap_ssid=nil ap_pwd=nil
|
||||
|
||||
wifi_init2=tmr.create()
|
||||
wifi_init2:alarm(120*1000, tmr.ALARM_SINGLE, function()
|
||||
print("BOOOOUM, y'a plus de AP WIFI !")
|
||||
wifi.setmode(wifi.STATION,true) wifi_init2=nil
|
||||
function wifi_init_end()
|
||||
wifi_init1:unregister() zLED=nil i=nil
|
||||
f= "wifi_info.lua" if file.exists(f) then dofile(f) end
|
||||
f=nil secrets_wifi=nil cli_pwd=nil cli_ssid=nil
|
||||
wifi_init1=nil wifi_init=nil
|
||||
print(node.heap()) collectgarbage() print(node.heap())
|
||||
end)
|
||||
boot2_go = true
|
||||
wifi_init_end=nil
|
||||
end
|
||||
|
||||
--zLED=4 -- NodeMCU
|
||||
zLED=7 -- SonOff
|
||||
gpio.write(zLED, gpio.HIGH) gpio.mode(zLED, gpio.OUTPUT)
|
||||
i=1
|
||||
wifi_init1=tmr.create()
|
||||
wifi_init1:alarm(1*1000, tmr.ALARM_AUTO , function()
|
||||
gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH)
|
||||
if wifi.sta.getip() == nil then
|
||||
print("Connecting to AP...")
|
||||
i=i+1
|
||||
if i > 5 then
|
||||
i=nil wifi_init1:unregister()
|
||||
print("pas glop :-(")
|
||||
if file.exists("_setup_wifi_") then
|
||||
file.remove("_setup_wifi_")
|
||||
print("setup wifi...")
|
||||
enduser_setup.start(function()
|
||||
node.restart()
|
||||
end)
|
||||
else
|
||||
-- charge les secrets pour le wifi
|
||||
f= "secrets_wifi.lua" if file.exists(f) then dofile(f) end
|
||||
f= "secrets_project.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
wifi_init2:unregister()
|
||||
wifi.setmode(wifi.SOFTAP,true)
|
||||
|
||||
f= "wifi_info.lua" if file.exists(f) then dofile(f) end
|
||||
boot2_go = true
|
||||
|
||||
--enduser_setup.start(function()
|
||||
-- node.restart()
|
||||
--end)
|
||||
wifi.setmode(wifi.STATIONAP,true)
|
||||
|
||||
wifi.sta.config{ssid=cli_ssid, pwd=cli_pwd, auto=true, save=true}
|
||||
wifi.sta.autoconnect(1) wifi.sta.connect()
|
||||
|
||||
if node_id == nil then node_id = "generic" end
|
||||
wifi.ap.config({ ssid = ap_ssid.."_"..node_id, pwd = ap_pwd, save=true })
|
||||
ap_ssid=nil ap_pwd=nil
|
||||
|
||||
wifi_init2=tmr.create()
|
||||
wifi_init2:alarm(60*1000, tmr.ALARM_SINGLE, function()
|
||||
print("BOOOOUM, y'a plus de AP WIFI !")
|
||||
wifi.setmode(wifi.STATION,true) wifi_init2=nil
|
||||
print(node.heap()) collectgarbage() print(node.heap())
|
||||
end)
|
||||
|
||||
--zLED=4 -- NodeMCU
|
||||
zLED=7 -- SonOff
|
||||
gpio.write(zLED, gpio.HIGH) gpio.mode(zLED, gpio.OUTPUT) i=1
|
||||
wifi_init1=tmr.create()
|
||||
wifi_init1:alarm(1*1000, tmr.ALARM_AUTO , function()
|
||||
gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH)
|
||||
if wifi.sta.getip() == nil then
|
||||
print("Connecting to AP...")
|
||||
i=i+1
|
||||
if i > 15 then
|
||||
print("pas de wifi :-(")
|
||||
wifi_init2:unregister() wifi_init2=nil
|
||||
wifi_init_end()
|
||||
end
|
||||
else
|
||||
wifi_init_end()
|
||||
end
|
||||
else
|
||||
wifi_init1:unregister() zLED=nil i=nil
|
||||
f= "wifi_info.lua" if file.exists(f) then dofile(f) end
|
||||
boot2_go = true
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
wifi_init()
|
||||
|
||||
--[[
|
||||
file.putcontents("_setup_wifi_", "")
|
||||
]]
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<title>SonOff home page</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>SonOff home page 200105.2228</h1>
|
||||
<h1>SonOff home page 200106.1842</h1>
|
||||
<h2>Menu:</h2>
|
||||
<h3>
|
||||
<a href="api_sonoff.html?LED=on">SonOff API LED On</a><br>
|
||||
@@ -13,6 +13,9 @@
|
||||
<a href="api_sonoff.html?RELAY=on">SonOff API RELAY On</a><br>
|
||||
<a href="api_sonoff.html?RELAY=off">SonOff API RELAY OFF</a><br>
|
||||
<br>
|
||||
|
||||
<a href="z_index.html?SetupWIFI=true">Wifi setup (setup_gadget, 192.168.4.1)</a><br>
|
||||
|
||||
<a href="wifi_clear.html?field1=11&field2=12&field3=13">Wifi clear, effacement configuration WIFI</a><br>
|
||||
<a href="disp_temp.html">Affichage des températures, affiche les températures mesurées</a><br>
|
||||
</h3>
|
||||
@@ -28,17 +31,12 @@
|
||||
end
|
||||
end
|
||||
if (_GET.SetupWIFI == "true") then
|
||||
|
||||
zout("setup wifi...")
|
||||
print("toto")
|
||||
--wifi.setmode(wifi.NULLMODE)
|
||||
--enduser_setup.start(function()
|
||||
-- node.restart()
|
||||
--end)
|
||||
|
||||
|
||||
|
||||
|
||||
zout("WIFI SETUP MODE")
|
||||
file.putcontents("_setup_wifi_", "")
|
||||
tmr.create():alarm(3*1000, tmr.ALARM_SINGLE, function()
|
||||
node.restart()
|
||||
end)
|
||||
end
|
||||
if (_GET.RESTART == "true") then
|
||||
|
||||
|
||||
Reference in New Issue
Block a user