Marche plus car je suis en train de changer ma façon de gérer l'horloge

This commit is contained in:
Christian Zufferey
2020-08-15 12:56:17 +02:00
parent 94ffe17fcc
commit a86ea289b5
4 changed files with 49 additions and 75 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 zf200727.2113 \n")
print("\n dsleep2.lua zf200815.1245 \n")
zLED=4
f= "flash_led_xfois.lua" if file.exists(f) then dofile(f) end
@@ -28,89 +28,19 @@ function dsleep_on()
-- end)
end
--[[
dsleep_on()
print(node.bootreason())
print("le flag est à "..rtcmem.read32(10))
f= "wifi_info.lua" if file.exists(f) then dofile(f) end
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())
]]
-- 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...")
print("Pas de réseau donc je scan le wifi...")
f = "0_wifi_scan.lua" if file.exists(f) then dofile(f) end
wifi.setmode(wifi.STATION)
scan_wifi()
else
print("Connected...")
print("Y'a du réseau donc je m'arrête...")
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()
-- end
-- function watch_wifi_on()
-- dsleep_on()
-- ztmr_watch_wifi_on = tmr.create()
-- ztmr_watch_wifi_on:alarm(1*1000, tmr.ALARM_AUTO , function()
-- if wifi.sta.getip() == nil then
-- -- print("Unconnected... (on)")
-- else
-- ztmr_watch_wifi_on:stop()
-- print("Connected... (on)")
-- -- f= "wifi_info.lua" if file.exists(f) then dofile(f) end
-- watch_wifi_off()
-- end
-- end)
-- end
-- function watch_wifi_off()
-- dsleep_off()
-- ztmr_watch_wifi_on:unregister()
-- ztmr_watch_wifi_off = tmr.create()
-- ztmr_watch_wifi_off:alarm(1*1000, tmr.ALARM_AUTO , function()
-- if wifi.sta.getip() == nil then
-- ztmr_watch_wifi_off:stop()
-- print("Unconnected... (off)")
-- watch_wifi_on()
-- ztmr_watch_wifi_off:unregister()
-- else
-- -- print("Connected... (off)")
-- xfois = 2
-- blink_LED ()
-- end
-- end)
-- end
-- watch_wifi_on()
dsleep_wake_up()

View File

@@ -1,15 +1,40 @@
# Quelques commandes remote (luatool) à envoyer avec le plugin Atom-IDE-terminal de l'éditeur Atom
# zf200814.1936
# zf200815.1253
Todo à faire pour ce projet !
- il faut que quand il se réveille et que la date est en 1970, il doit alors aller
J'ai encore 3x problèmes à régler !
- comment faire pour sauver l'horloge afin d'avoir une horloge quand on n'a pas
eu de connexion internet au moment du power on ?
1: il faut que quand il se réveille et que la date est en 1970, il doit alors aller
chercher la date dans un fichier sur la flash.
Et qu'à chaque fois qu'il écrit le log dans la flash il sauve aussi la date qu'il
a pour si jamais qu'il puisse repartir au moins depuis un temps connu
- comment se comporter quand on a trouvé un WIFI connu ?
Afin de pouvoir
1) se connecter pour vider les logs
2) récupérer l'horloge
3) faire la maintenance
4) continuer quand même le recording
1: s'il voit apzuzu6, il se connecte et va régler l'horloge et continue son dsleep habituel
2: s'il voit 3g-s7, il se connecte et va régler l'horloge et arrête son dsleep
- comment avoir une balise de recherche quand le pet tracker est perdu ?
Convertisseur GPX to CSV
https://mygeodata.cloud/converter/gpx-to-csv

View File

@@ -0,0 +1,19 @@
-- Scripts pour régler l'horloge quand on est connecté en WIFI
print("\n set_time2.lua zf200815.1255 \n")
function set_time()
sntp.sync(nil, nil, nil, 1)
end
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
set_time()
--[[
print(ztime())
]]