diff --git a/DeepSleep/Pet_tracker_3/0_wifi_scan.lua b/DeepSleep/Pet_tracker_3/0_wifi_scan.lua index 8702a92..efdccc7 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 zf200815.1454 \n") +print("\n wifi_scan.lua zf200816.1417 \n") f= "secrets_project.lua" if file.exists(f) then dofile(f) end @@ -12,7 +12,7 @@ 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() + file.open(logs_ap_wifi, "a+") file.writeline(zstr) file.close() end -- print AP list in new format diff --git a/DeepSleep/Pet_tracker_3/_zremote_cmd.txt b/DeepSleep/Pet_tracker_3/_zremote_cmd.txt index 57663e3..4d09612 100644 --- a/DeepSleep/Pet_tracker_3/_zremote_cmd.txt +++ b/DeepSleep/Pet_tracker_3/_zremote_cmd.txt @@ -1,9 +1,11 @@ # Quelques commandes remote (luatool) à envoyer avec le plugin Atom-IDE-terminal de l'éditeur Atom -# zf200815.1253 +# zf200816.1420 Todo à faire pour ce projet ! +- éviter de trop remplir la FLASH ! + J'ai encore 3x problèmes à régler ! diff --git a/DeepSleep/Pet_tracker_3/cat2.lua b/DeepSleep/Pet_tracker_3/cat2.lua index e65efaa..9ed78f4 100644 --- a/DeepSleep/Pet_tracker_3/cat2.lua +++ b/DeepSleep/Pet_tracker_3/cat2.lua @@ -1,5 +1,5 @@ -- fonction cat() pour afficher le contenu d'un fichier dans la flash -print("\n cat2.lua zf200725.1319 \n") +print("\n cat2.lua zf200816.1417 \n") print("\nusage:") print(" cat2(\"filename\")") @@ -17,7 +17,7 @@ function zprintline() end function cat2() - zfilei = file.open(z_logs_ap_wifi, "r") + zfilei = file.open(logs_ap_wifi, "r") zline = file.readline() ztmr_cat1:alarm(50, tmr.ALARM_AUTO, zprintline) end diff --git a/DeepSleep/Pet_tracker_3/initz.lua b/DeepSleep/Pet_tracker_3/initz.lua index 60d980e..71605af 100644 --- a/DeepSleep/Pet_tracker_3/initz.lua +++ b/DeepSleep/Pet_tracker_3/initz.lua @@ -3,7 +3,7 @@ -- le script repair.lua pendant xx secondes avant de continuer --Source: https://nodemcu.readthedocs.io/en/master/en/modules/node/#nodebootreason -print("\n init.lua zf200725.1150 \n") +print("\n init.lua zf200816.1421 \n") verbose = true @@ -52,22 +52,40 @@ function initz() print("reset_reason: ",reset_reason) if reset_reason == 0 then print("power on") - second_chance() + if node_mode == "dsleep" then + print("dsleep wake up") + f = "0_dsleep2.lua" if file.exists(f) then dofile(f) end + else + second_chance() + end elseif reset_reason == 4 then print("node.restart") initz_end() elseif reset_reason == 5 then print("dsleep wake up") - initz_end() + if node_mode == "dsleep" then + print("dsleep wake up") + f = "0_dsleep2.lua" if file.exists(f) then dofile(f) end + else + initz_end() + end elseif reset_reason == 6 then print("external reset") - print("dsleep wake up") - f = "0_dsleep2.lua" if file.exists(f) then dofile(f) end + if node_mode == "dsleep" then + print("dsleep wake up") + f = "0_dsleep2.lua" if file.exists(f) then dofile(f) end + else + initz_end() + end else print("autre raison") second_chance() end end + +f= "secrets_wifi.lua" if file.exists(f) then dofile(f) end +f= "secrets_project.lua" if file.exists(f) then dofile(f) end + initz() --[[ diff --git a/DeepSleep/Pet_tracker_3/wifi_init.lua b/DeepSleep/Pet_tracker_3/wifi_init.lua index 2a61c34..05f9727 100644 --- a/DeepSleep/Pet_tracker_3/wifi_init.lua +++ b/DeepSleep/Pet_tracker_3/wifi_init.lua @@ -1,10 +1,10 @@ -- Petit script pour initaliser la couche WIFI function wifi_init() - print("\n wifi_init.lua zf200814.1917 \n") + print("\n wifi_init.lua zf200816.1435 \n") - f= "secrets_wifi.lua" if file.exists(f) then dofile(f) end - f= "secrets_project.lua" if file.exists(f) then dofile(f) end + -- f= "secrets_wifi.lua" if file.exists(f) then dofile(f) end + -- f= "secrets_project.lua" if file.exists(f) then dofile(f) end function wifi_init_end() tmr_wifi_init1:unregister() i=nil @@ -29,28 +29,28 @@ function wifi_init() end if file.exists("_setup_wifi_") then - print("dsleep wake up") - file.remove("_setup_wifi_") - f = "0_dsleep2.lua" if file.exists(f) then dofile(f) end - - -- - -- print("setup wifi...") + -- print("dsleep wake up") -- file.remove("_setup_wifi_") - -- wifi.sta.config{ssid="", pwd=""} wifi.sta.connect() - -- if zLED == nil then zLED = 4 end - -- gpio.write(zLED, gpio.HIGH) gpio.mode(zLED, gpio.OUTPUT) - -- tmr_wifi_init4=tmr.create() - -- tmr_wifi_init4:alarm(0.1*1000, tmr.ALARM_AUTO , function() - -- gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) - -- end) - -- tmr.create():alarm(90*1000, tmr.ALARM_SINGLE, function() - -- node.restart() - -- end) - -- enduser_setup.start(function() - -- print("on est sortit du setup wifi et on restart !") - -- node.restart() - -- end) - -- print("setup gadget lancé...") + -- f = "0_dsleep2.lua" if file.exists(f) then dofile(f) end + + + print("setup wifi...") + file.remove("_setup_wifi_") + wifi.sta.config{ssid="", pwd=""} wifi.sta.connect() + if zLED == nil then zLED = 4 end + gpio.write(zLED, gpio.HIGH) gpio.mode(zLED, gpio.OUTPUT) + tmr_wifi_init4=tmr.create() + tmr_wifi_init4:alarm(0.1*1000, tmr.ALARM_AUTO , function() + gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) + end) + tmr.create():alarm(90*1000, tmr.ALARM_SINGLE, function() + node.restart() + end) + enduser_setup.start(function() + print("on est sortit du setup wifi et on restart !") + node.restart() + end) + print("setup gadget lancé...") else