Amélioré l'api sur SonOff. J'ai toujours le wifi setup qui reboot quand il a une adresse ip de valide :-(

This commit is contained in:
Christian Zufferey
2020-01-12 17:11:01 +01:00
parent 411d725bb5
commit 639be69b97
3 changed files with 40 additions and 51 deletions

View File

@@ -1,24 +1,27 @@
# Quelques commandes remote (luatool) à envoyer avec le plugin Atom-IDE-terminal de l'éditeur Atom
# zf200110.1826
# zf200112.1710
Todo à faire pour ce projet !
- ajouter fonction restart dans z_index.html (ATTENTION avec un argument restart, pas besoin de faire une page restart.html !)
- ajouter l'affichage du node_id dans z_index.html
- ajouter le contrôle flip/flop du btn sur RELAY
- ajouter une page affichage variables globales
- améliorer le résultat de api_sonoff.html, il faut sortir l'état des IO lors d'un changement comme confirmation
- enlever la ligne wifi init dans z_index.html
- if verbose print partout dans *.lua
- le wifi setup ne fonctionne toujours pas quand il y a déjà un ap de connecté (problème du reboot quand adrs ip ok)!
v- ajouter fonction restart dans z_index.html (ATTENTION avec un argument restart, pas besoin de faire une page restart.html !)
v- ajouter le web_srv2 dans boot au lieu de boot2
v- ajouter un état du RELAY et de la LED dans z_index.html
v- ajouter une page affichage variables globales
v- améliorer api_sonoff.html, il faut ajouter 'home' sur la page
v- améliorer le résultat de api_sonoff.html, il faut sortir l'état des IO lors d'un changement comme confirmation
v- copier secrets_project et secrets_wifi dans _secrets_project_ _secrets_wifi_ pour la documentation
v- déplacer le mode AP dans wifi_init
v- enlever la ligne wifi init dans z_index.html
v- faire la page web service pour allumer la LED
v- faire la page web service pour allumer le relay
v- 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
v- passer à 15x les tentatives de connexions au WIFI
v- vérifier le fonctionnement d'allumer la LED, car ne marche plus !
x- mettre ZLED2 et ZRELAY dans secrets_project
x-ajouter argument ok dans wifi_init.html (sécurité)

View File

@@ -1,38 +1,34 @@
<!DOCTYPE html>
<!-- ATTENTION, la longueur des lignes DOIT être <128 ! -->
<html lang="fr" dir="ltr">
<head>
<meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>
<title>API SonOff</title>
</head>
<body>
<h1>API SonOff 200109.1851</h1>
<br>
<%
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.LED == "on") then
gpio.write(zLED, gpio.LOW) gpio.mode(zLED, gpio.OUTPUT)
end
if (_GET.LED == "off") then
gpio.write(zLED, gpio.HIGH) gpio.mode(zLED, gpio.OUTPUT)
end
if (_GET.RELAY == "on") then
zRELAY=6
gpio.mode(zRELAY, gpio.OUTPUT) gpio.write(zRELAY, gpio.HIGH)
end
if (_GET.RELAY == "off") then
zRELAY=6
gpio.mode(zRELAY, gpio.OUTPUT) gpio.write(zRELAY, gpio.LOW)
end
%>
</body>
<head>
<meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>
<title>API SonOff</title>
</head>
<body>
<h1>API SonOff zf200112.1706</h1>
<a href="/">Home...</a><br><br>
<%
if _GET.LED == "on" then
gpio.write(zLED, gpio.LOW) gpio.mode(zLED, gpio.OUTPUT)
zout("LED=".._GET.LED.."<br>")
end
if _GET.LED == "off" then
gpio.write(zLED, gpio.HIGH) gpio.mode(zLED, gpio.OUTPUT)
zout("LED=".._GET.LED.."<br>")
end
%>
<%
if _GET.RELAY == "on" then
gpio.mode(zRELAY, gpio.OUTPUT) gpio.write(zRELAY, gpio.HIGH)
zout("RELAY=".._GET.RELAY.."<br>")
end
if _GET.RELAY == "off" then
gpio.mode(zRELAY, gpio.OUTPUT) gpio.write(zRELAY, gpio.LOW)
zout("RELAY=".._GET.RELAY.."<br>")
end
%>
</body>
</html>

View File

@@ -8,7 +8,7 @@
<title>SonOff home page</title>
</head>
<body>
<h1>SonOff home page 2001012.1634</h1>
<h1>SonOff home page 2001012.1707</h1>
<a href="/">Home...</a><br>
<h2>Menu:</h2>
<h3>
@@ -27,16 +27,6 @@
<a href="z_index.html?SetupWIFI=true">Wifi setup</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
print("On demande le setup wifi depuis le browser !")