Cela commence à bien enregistrer dans la flash maintenant ;-)

This commit is contained in:
Christian Zufferey
2020-07-24 18:40:53 +02:00
parent 7394b7931e
commit 1a69277497
3 changed files with 39 additions and 22 deletions

View File

@@ -3,10 +3,11 @@
-- ATTENTION: il faut connecter la pin 0 à la pin RESET avec une résistance de 1k !
print("\n dsleep.lua zf200722.1944 \n")
print("\n dsleep.lua zf200724.1803 \n")
zLED=4
f= "flash_led_xfois.lua" if file.exists(f) then dofile(f) end
f= "secrets_project.lua" if file.exists(f) then dofile(f) end
function ztime()
tm = rtctime.epoch2cal(rtctime.get()+2*3600)
@@ -57,15 +58,22 @@ function dsleep_wake_up()
print("Connected...")
end
-- f= "wifi_info.lua" if file.exists(f) then dofile(f) end
end
function zcat_logs_ap_wifi()
zfilei = file.open(z_logs_ap_wifi, "r")
zline=file.readline()
repeat
print(string.sub(zline,1,string.len(zline)-1))
zline=file.readline()
until zline== nil
file.close(zfilei)
end
-- function dsleep_off()
-- print("timer dsleep off...")
-- ztmr_SLEEP:unregister()

View File

@@ -1,31 +1,36 @@
-- Scripts pour tester l'écoute des AP WIFI
print("\n wifi_scan.lua zf200722.1944 \n")
print("\n wifi_scan.lua zf200724.1827 \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
--f= "wifi_cli_start.lua" if file.exists(f) then dofile(f) end
--f= "telnet_srv.lua" if file.exists(f) then dofile(f) end
--f= "web_ide2.lua" if file.exists(f) then dofile(f) end
--f= "dsleep.lua" if file.exists(f) then dofile(f) end
-- https://www.epochconverter.com/
ztime2020 = 1577836800 -- Unix time pour 1.1.2020 0:0:0 GMT
-- sauvegarde les données dans la flash du NodeMCU
function save_flash(zstr_ap_wifi)
ztime1 = tostring(rtctime.get() + 2*3600 - ztime2020)
local zstr = ztime1..", "..zstr_ap_wifi
if verbose then print("saving to flash: "..zstr) end
file.open(z_logs_ap_wifi, "a+") file.writeline(zstr) file.close()
end
-- print AP list in new format
function scan_wifi()
print(ztime())
function listap(t)
print("on affiche le résultat...")
print("start display liste ap wifi...")
for k,v in pairs(t) do
local ssid, rssi, authmode, channel = string.match(v, "([^,]+),([^,]+),([^,]+),([^,]*)")
print(ssid,rssi)
-- print(k.." : "..v)
-- local ssid, rssi, authmode, channel = string.match(v, "([^,]+),([^,]+),([^,]+),([^,]*)")
-- print(ssid,rssi)
-- print(k.." : "..v)
-- local zstr = k..", "..v
local zstr = v
save_flash(zstr)
end
print("on a terminé d'afficher...")
print("end display...")
dsleep_on()
end
print("on scanne...")
print("wifi scan...")
wifi.sta.getap(1, listap)
print("on a terminé...")
end
--[[

View File

@@ -1,11 +1,15 @@
zf200722.1944
zf200724.1053
print(ztime())
dsleep_on()
zcat_logs_ap_wifi()
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()