diff --git a/.gitignore b/.gitignore index 6c74031..75a6ff9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +eus_params* secret* credential* Icon? @@ -46,4 +47,3 @@ luac.out *.i*86 *.x86_64 *.hex - diff --git a/Mesures/humidity/bolo/0_send_data.lua b/Mesures/humidity/bolo/0_send_data.lua index e78c622..62c195c 100644 --- a/Mesures/humidity/bolo/0_send_data.lua +++ b/Mesures/humidity/bolo/0_send_data.lua @@ -1,6 +1,6 @@ -- Petit script pour envoyer les valeurs sur un serveur WEB (InfluxDB) -- via un http GET -print("\n 0_send_data.lua zf191217.2217 \n") +print("\n 0_send_data.lua zf191222.1711 \n") function zpost(zarg) if verbose then print("zarg: "..zarg) end @@ -22,8 +22,8 @@ function send_data() if verbose then print("Temperature: "..ztemp.." °C") end if verbose then print("Humidity: "..zhumd.." %") end - zpost("bolo_ruru,capteur="..th_id.." humidity="..zhumd) - zpost("bolo_ruru,capteur="..th_id.." temperature="..ztemp) + zpost("bolo_ruru,capteur=th"..node_id.." humidity="..zhumd) + zpost("bolo_ruru,capteur=th"..node_id.." temperature="..ztemp) -- print("titi") end diff --git a/Mesures/humidity/bolo/_secrets_project.lua_ b/Mesures/humidity/bolo/_secrets_project.lua_ index 098e973..4e021de 100644 --- a/Mesures/humidity/bolo/_secrets_project.lua_ +++ b/Mesures/humidity/bolo/_secrets_project.lua_ @@ -5,24 +5,24 @@ -- par 'boot2.lua' au moment du boot function secrets_project() - print("\n secrets_project.lua zf191218.0818 \n") + print("\n secrets_project.lua zf191222.1709 \n") influxdb_url="http://www.xxx.ml:8086/write?db=xxx&u=admin&p=xxx" print("influxdb_url: "..influxdb_url) - th_id = "generic" + node_id = "generic" - if node.chipid() == 3049014 then th_id = "th0" end - if node.chipid() == 3049553 then th_id = "th1" end - if node.chipid() == 14975023 then th_id = "th2" end - if node.chipid() == 14972372 then th_id = "th3" end - if node.chipid() == 12557128 then th_id = "th4" end - if node.chipid() == 3048165 then th_id = "th5" end - if node.chipid() == 14973009 then th_id = "th6" end + if node.chipid() == 3049014 then node_id = "0" end + if node.chipid() == 3049553 then node_id = "1" end + if node.chipid() == 14975023 then node_id = "2" end + if node.chipid() == 14972372 then node_id = "3" end + if node.chipid() == 12557128 then node_id = "4" end + if node.chipid() == 3048165 then node_id = "5" end + if node.chipid() == 14973009 then node_id = "6" end - print("th_id: "..th_id) + print("node_id: "..node_id) end secrets_project() diff --git a/Mesures/humidity/bolo/boot2.lua b/Mesures/humidity/bolo/boot2.lua index a0a20cd..a7c995e 100644 --- a/Mesures/humidity/bolo/boot2.lua +++ b/Mesures/humidity/bolo/boot2.lua @@ -1,20 +1,25 @@ -- Scripts à charger après le boot pour démarrer son projet -print("\n boot2.lua zf191221.1554 \n") +print("\n boot2.lua zf191222.1827 \n") function boot2() second_chance=nil initz=nil boot=nil zLED=nil boot2_tmr=nil secrets_wifi=nil wifi_init=nil - cli_ssid=nil cli_pwd=nil ap_ssid=nil ap_pwd=nil + cli_ssid=nil cli_pwd=nil boot2_tmr1=nil wifi_init1=nil wifi_info=nil boot2_go=nil f= "secrets_project.lua" if file.exists(f) then dofile(f) end f= "set_time.lua" if file.exists(f) then dofile(f) end collectgarbage() - f= "0_htu21d.lua" if file.exists(f) then dofile(f) end - f= "0_send_data.lua" if file.exists(f) then dofile(f) end - f= "0_cron.lua" if file.exists(f) then dofile(f) end + + wifi.setmode(wifi.STATIONAP,true) + wifi.ap.config({ ssid = ap_ssid.."_"..node_id, pwd = ap_pwd, save=true }) + ap_ssid=nil ap_pwd=nil f= "web_srv2.lua" if file.exists(f) then dofile(f) end + + --f= "0_htu21d.lua" if file.exists(f) then dofile(f) end + --f= "0_send_data.lua" if file.exists(f) then dofile(f) end + --f= "0_cron.lua" if file.exists(f) then dofile(f) end --f= "web_ide2.lua" if file.exists(f) then dofile(f) end f=nil diff --git a/Mesures/humidity/bolo/wifi_init.lua b/Mesures/humidity/bolo/wifi_init.lua index 4270a98..78f529f 100644 --- a/Mesures/humidity/bolo/wifi_init.lua +++ b/Mesures/humidity/bolo/wifi_init.lua @@ -1,24 +1,30 @@ -- Petit script pour initaliser la couche WIFI function wifi_init() - print("\n wifi_init.lua zf191221.1536 \n") + print("\n wifi_init.lua zf191222.1825 \n") -- charge les secrets pour le wifi f= "secrets_wifi.lua" if file.exists(f) then dofile(f) end wifi.setmode(wifi.STATION,true) --- wifi.setmode(wifi.STATIONAP,true) --- wifi.ap.config({ ssid = ap_ssid.." "..wifi.ap.getmac(), pwd = ap_pwd, save=true }) - wifi.sta.config{ssid=cli_ssid, pwd=cli_pwd, auto=true, save=true} wifi.sta.autoconnect(1) wifi.sta.connect() zLED=4 gpio.write(zLED, gpio.HIGH) gpio.mode(zLED, gpio.OUTPUT) + i=0 wifi_init1=tmr.create() wifi_init1:alarm(1*1000, tmr.ALARM_AUTO , function() gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) if wifi.sta.getip() == nil then print("Connecting to AP...") + i=i+1 + if i > 7 then + wifi_init1:unregister() + print("booum!") + enduser_setup.start(function() + node.restart() + end) + end else wifi_init1:unregister() zLED=nil f= "wifi_info.lua" if file.exists(f) then dofile(f) end