From cca4683200a731dca2a7bf55e463fc35b6e30449 Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Sat, 15 Aug 2020 15:02:46 +0200 Subject: [PATCH] =?UTF-8?q?Voil=C3=A0,=20il=20est=20maintenant=20capable?= =?UTF-8?q?=20de=20repartir=20sur=20une=20ancienne=20heure=20apr=C3=A8s=20?= =?UTF-8?q?un=20power=20boot=20Bien=20qu'il=20n'a=20pas=20de=20connexion?= =?UTF-8?q?=20r=C3=A9seau=20au=20moment=20du=20power=20boot,=20il=20peut?= =?UTF-8?q?=20retrouver=20une=20ancienne=20heure=20sauvegard=C3=A9e=20dans?= =?UTF-8?q?=20la=20flash=20et=20continuer=20=C3=A0=20enregistrer.=20Il=20f?= =?UTF-8?q?aut=20maintenant=20qu'il=20voit=20que=20quand=20il=20a=20un=20w?= =?UTF-8?q?ifi=20connu=20qu'il=20se=20connecte=20sur=20Internet=20pour=20s?= =?UTF-8?q?e=20resynchroniser=20avec=20la=20bonne=20heure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DeepSleep/Pet_tracker_3/0_dsleep2.lua | 8 +++++++- DeepSleep/Pet_tracker_3/0_wifi_scan.lua | 5 ++++- DeepSleep/Pet_tracker_3/boot.lua | 6 +++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/DeepSleep/Pet_tracker_3/0_dsleep2.lua b/DeepSleep/Pet_tracker_3/0_dsleep2.lua index 265b343..d27865e 100644 --- a/DeepSleep/Pet_tracker_3/0_dsleep2.lua +++ b/DeepSleep/Pet_tracker_3/0_dsleep2.lua @@ -3,7 +3,7 @@ -- ATTENTION: il faut connecter la pin 0 à la pin RESET avec une résistance de 1k ! -print("\n dsleep2.lua zf200815.1245 \n") +print("\n dsleep2.lua zf200815.1430 \n") zLED=4 f= "flash_led_xfois.lua" if file.exists(f) then dofile(f) end @@ -32,6 +32,12 @@ end -- 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 rtctime.get() < 1597494477 then + print("oups je n'ai pas la bonne heure...") + rtctime.set(file.getcontents("_ztime_")) + print("voilà j'ai retrouvé une ancienne heure "..ztime()) + + end if wifi.sta.getip() == nil then print("Pas de réseau donc je scan le wifi...") f = "0_wifi_scan.lua" if file.exists(f) then dofile(f) end diff --git a/DeepSleep/Pet_tracker_3/0_wifi_scan.lua b/DeepSleep/Pet_tracker_3/0_wifi_scan.lua index 0258434..8702a92 100644 --- a/DeepSleep/Pet_tracker_3/0_wifi_scan.lua +++ b/DeepSleep/Pet_tracker_3/0_wifi_scan.lua @@ -1,6 +1,6 @@ -- Scripts pour tester l'écoute des AP WIFI -print("\n wifi_scan.lua zf200814.1924 \n") +print("\n wifi_scan.lua zf200815.1454 \n") f= "secrets_project.lua" if file.exists(f) then dofile(f) end @@ -37,6 +37,9 @@ function scan_wifi() save_flash(zstr) end print("end display...") + -- sauve l'heure sur la flash pour si jamais il y a un boot power on sans Internet + file.putcontents("_ztime_", rtctime.get()) + if zdsleep_stop then node.restart() else diff --git a/DeepSleep/Pet_tracker_3/boot.lua b/DeepSleep/Pet_tracker_3/boot.lua index 77ce385..436753f 100644 --- a/DeepSleep/Pet_tracker_3/boot.lua +++ b/DeepSleep/Pet_tracker_3/boot.lua @@ -1,7 +1,7 @@ -- Scripts à charger après le boot pour démarrer son projet function boot() - print("\n boot.lua zf200815.1358 \n") + print("\n boot.lua zf200815.1436 \n") print("On lance le boot...") collectgarbage() print(node.heap()) local f @@ -16,8 +16,8 @@ function boot() f = "set_time2.lua" if file.exists(f) then dofile(f) end print(node.heap()) collectgarbage() print(node.heap()) - f = "0_dsleep2.lua" if file.exists(f) then dofile(f) end - print(node.heap()) collectgarbage() print(node.heap()) + -- 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())