beuhh, ma superbe procédure de configuration automatique du wifi ne fonctionne plus :-(

This commit is contained in:
Christian Zufferey
2020-01-06 00:17:23 +01:00
parent f3ee385aab
commit 40ab0cde4b
5 changed files with 112 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
# Quelques commandes remote (luatool) à envoyer avec le plugin Atom-IDE-terminal de l'éditeur Atom
# zf200103.1217
# zf200105.0016
Todo à faire pour ce projet !
@@ -7,6 +7,7 @@ Todo à faire pour ce projet !
- ajouter l'affichage du node_id dans z_index.html
- ajouter argument ok dans wifi_init.html (sécurité)
- ajouter le contrôle flip/flop du btn sur RELAY
- ajouter une page affichage variables globales
- if verbose print partout dans 0_send_data.lua
- garder variable node_id pour identification après poweron général, reattribution adrs ip sur modem 4G
v- passer à 10 secondes la seconde chance
@@ -51,6 +52,7 @@ for k,v in pairs(_G) do print(k,v) end
# commandes lua pour ce projet
export zIP="192.168.0.156"
export zIP="192.168.4.1"
export zport="23"
./luatool.py --ip $zIP:$zport -f z_index.html
./luatool.py --ip $zIP:$zport -f api_sonoff.html

View File

@@ -1,9 +1,49 @@
print('\\n-----')
local l = file.list()
table.sort(l)
for k,v in pairs(l) do print(k..', size:'..v)end
print('-----\\n')
print("a start... zf190105.2344")
zdir={};pfile = file.list();for k,v in pairs(pfile) do zdir[#zdir+1] = k..string.rep(" ",24-string.len(k)).." : "..v end;table.sort(zdir);print('\n-----');for i=1, #zdir do print(zdir[i]) end;print('-----\n');zdir=nil;pfile=nil;k=nil;v=nil;i=nil
srv:close()
srv=nil
wifi.setmode(wifi.NULLMODE,true)
print("toto")
tmr.delay(1*1000*1000)
print("tutu")
wifi.setmode(wifi.STATIONAP,true)
wifi.sta.config{ssid="", pwd="", auto=true, save=true}
wifi.sta.autoconnect(1) wifi.sta.connect()
wifi.ap.config({ ssid = "toto", auth=wifi.OPEN, save=true })
wifi.setmode(wifi.STATION,true)
--wifi.setmode(wifi.STATIONAP)
--wifi.ap.config({ssid="MyPersonalSSID", auth=wifi.OPEN})
--enduser_setup.manual(true)
--[[
srv:close()
srv=nil
wifi.setmode(wifi.NULLMODE,true)
print("toto")
a1=tmr.create()
a1:alarm(10*1000, tmr.ALARM_SINGLE, function()
enduser_setup.start(
function()
print("Connected to WiFi as:" .. wifi.sta.getip())
end,
function(err, str)
print("enduser_setup: Err #" .. err .. ": " .. str)
end,
print -- Lua print function can serve as the debug callback
)
print(node.heap()) collectgarbage() print(node.heap())
print("tutu")
end)
]]

View File

@@ -1,11 +1,13 @@
-- Scripts à charger après le boot pour démarrer le core system
print("\n boot.lua zf200101.1235 \n")
print("\n boot.lua zf200105.2358 \n")
function boot()
gpio.trig(zswitch, "none") hvbouton=nil zswitch=nil reset_reason=nil
if zswitch ~= nill then
gpio.trig(zswitch, "none") hvbouton=nil zswitch=nil reset_reason=nil
end
f= "wifi_init.lua" if file.exists(f) then dofile(f) end
f= "telnet_srv2.lua" if file.exists(f) then dofile(f) end
f= "web_srv2.lua" if file.exists(f) then dofile(f) end
f= "wifi_init.lua" if file.exists(f) then dofile(f) end
end
boot()

View File

@@ -1,7 +1,7 @@
-- Petit script pour initaliser la couche WIFI
function wifi_init()
print("\n wifi_init.lua zf200101.1302 \n")
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
@@ -16,7 +16,7 @@ function wifi_init()
ap_ssid=nil ap_pwd=nil
wifi_init2=tmr.create()
wifi_init2:alarm(60*1000, tmr.ALARM_SINGLE, function()
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
print(node.heap()) collectgarbage() print(node.heap())
@@ -32,12 +32,19 @@ function wifi_init()
if wifi.sta.getip() == nil then
print("Connecting to AP...")
i=i+1
if i > 15 then
if i > 5 then
i=nil wifi_init1:unregister()
print("booum!")
enduser_setup.start(function()
node.restart()
end)
print("pas glop :-(")
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)
end
else
wifi_init1:unregister() zLED=nil i=nil

View File

@@ -5,7 +5,7 @@
<title>SonOff home page</title>
</head>
<body>
<h1>SonOff home page 200103.1212</h1>
<h1>SonOff home page 200105.2228</h1>
<h2>Menu:</h2>
<h3>
<a href="api_sonoff.html?LED=on">SonOff API LED On</a><br>
@@ -17,6 +17,45 @@
<a href="disp_temp.html">Affichage des températures, affiche les températures mesurées</a><br>
</h3>
<%
if (vars ~= nil) then
zout("<br>vars: "..vars.."<br>")
for k, v in string.gmatch(vars, "(%w+)=(%w+%p+%w+)&*") do
_GET[k] = v
zout(k..": "..v.."<br>")
end
end
if (_GET.SetupWIFI == "true") then
zout("setup wifi...")
print("toto")
--wifi.setmode(wifi.NULLMODE)
--enduser_setup.start(function()
-- node.restart()
--end)
end
if (_GET.RESTART == "true") then
zout("oups restart...")
end
%>
<br>Etat de la LED:<nsp>
<%
zLED=7 -- SonOff
@@ -31,8 +70,10 @@
<br><br>
<%
a,b,c = wifi.sta.getip()
zout("IP: "..a.."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MASK: "..b.."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GATEWAY: "..c.."<br>")
if wifi.sta.getip() ~= nil then
a,b,c = wifi.sta.getip()
zout("IP: "..a.."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MASK: "..b.."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GATEWAY: "..c.."<br>")
end
collectgarbage() zout("RAM: "..node.heap())
%>
</body>