Cela commence à marcher, il s'endore, se réveille, scan le réseau wifi et se rendort

This commit is contained in:
Christian Zufferey
2020-07-22 19:45:48 +02:00
parent 3e676db63d
commit 7394b7931e
4 changed files with 35 additions and 11 deletions

View File

@@ -3,7 +3,7 @@
-- ATTENTION: il faut connecter la pin 0 à la pin RESET avec une résistance de 1k !
print("\n dsleep.lua zf200722.1546 \n")
print("\n dsleep.lua zf200722.1944 \n")
zLED=4
f= "flash_led_xfois.lua" if file.exists(f) then dofile(f) end
@@ -48,6 +48,19 @@ print(ztime())
-- on se réveil, vérifie si on peut avoir du réseau autrement on va redormir
function dsleep_wake_up()
print("Coucou, je suis réveillé... et il est "..ztime())
if wifi.sta.getip() == nil then
print("Unconnected...")
f = "0_wifi_scan.lua" if file.exists(f) then dofile(f) end
wifi.setmode(wifi.STATION)
scan_wifi()
else
print("Connected...")
end
-- f= "wifi_info.lua" if file.exists(f) then dofile(f) end
end

View File

@@ -1,6 +1,6 @@
-- Scripts pour tester l'écoute des AP WIFI
print("\n a.lua zf200722.1544 \n")
print("\n wifi_scan.lua zf200722.1944 \n")
--f= "wifi_ap_stop.lua" if file.exists(f) then dofile(f) end
--f= "wifi_cli_conf.lua" if file.exists(f) then dofile(f) end
@@ -11,20 +11,25 @@ print("\n a.lua zf200722.1544 \n")
-- print AP list in new format
function a()
function scan_wifi()
print(ztime())
function listap(t)
print("")
print("on affiche le résultat...")
for k,v in pairs(t) do
print(k.." : "..v)
local ssid, rssi, authmode, channel = string.match(v, "([^,]+),([^,]+),([^,]+),([^,]*)")
print(ssid,rssi)
-- print(k.." : "..v)
end
print("")
print("on a terminé d'afficher...")
dsleep_on()
end
print("on scanne...")
wifi.sta.getap(1, listap)
print("on a terminé...")
end
--[[
a()
scan_wifi()
]]

View File

@@ -1,18 +1,21 @@
zf200722.1537
zf200722.1944
dsleep_on()
print(node.bootreason())
print("le flag est à "..rtcmem.read32(10))
f= "wifi_info.lua" if file.exists(f) then dofile(f) end
print(ztime())
wifi.setmode(wifi.STATION)
a()
wifi.setmode(wifi.NULLMODE,true)
function ztime()
tm = rtctime.epoch2cal(rtctime.get()+2*3600)
print(string.format("%04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"]))
end
print(ztime())

View File

@@ -1,7 +1,7 @@
-- Scripts à charger après le boot pour démarrer son projet
function boot()
print("\n boot.lua zf200722.1536 \n")
print("\n boot.lua zf200722.1944 \n")
print("On lance le boot...")
collectgarbage() print(node.heap())
local f
@@ -18,6 +18,9 @@ function boot()
f = "0_dsleep2.lua" if file.exists(f) then dofile(f) end
print(node.heap()) collectgarbage() print(node.heap())
-- f = "0_wifi_scan.lua" if file.exists(f) then dofile(f) end
-- print(node.heap()) collectgarbage() print(node.heap())
-- f = "flash_led_xfois.lua" if file.exists(f) then dofile(f) end
-- print(node.heap()) collectgarbage() print(node.heap())