From 70961043e4d54c33ab49d353e8e0f2ad00e7f321 Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Tue, 3 Mar 2020 00:05:54 +0100 Subject: [PATCH] =?UTF-8?q?Super=20bien=20nettoy=C3=A9=20mon=20workshop=20?= =?UTF-8?q?:-)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{blink_led_ko.lua => blink_led0_ko.lua} | 0 Workshop/181015/blink_led1.lua | 31 ++++---- Workshop/181015/blink_led2.lua | 31 ++++---- .../181015/btn_led_remote/btn/btn_led.lua | 4 +- .../btn_led_remote/btn/flash_led_xfois.lua | 6 +- .../181015/btn_led_remote/btn/start_boot.lua | 12 +-- .../181015/btn_led_remote/btn/web_cli.lua | 4 +- .../btn_led_remote/btn/wifi_cli_conf.lua | 5 +- .../181015/btn_led_remote/btn/wifi_get_ip.lua | 5 +- .../btn_led_remote/led/flash_led_xfois.lua | 6 +- .../btn_led_remote/led/wifi_cli_conf.lua | 5 +- .../181015/btn_led_remote/led/wifi_get_ip.lua | 4 +- .../181015/btn_led_remote/led/wifi_info.lua | 61 +++++++++------ Workshop/181015/flash_led_xfois.lua | 6 +- Workshop/181015/hello_world/blink_led1.lua | 2 +- Workshop/181015/hello_world/initz.lua | 4 +- Workshop/181015/{ => oldies}/btn_led.lua | 0 Workshop/181015/{ => oldies}/cat.lua | 0 Workshop/181015/{ => oldies}/dir.lua | 0 .../flash_led_xfois.lua | 8 +- Workshop/181015/{ => oldies}/initz.lua | 0 Workshop/181015/oldies/rm_files.lua | 12 +++ Workshop/181015/{ => oldies}/start_boot.lua | 0 Workshop/181015/{ => oldies}/start_job.lua | 0 Workshop/181015/{ => oldies}/telnet_srv.lua | 0 Workshop/181015/{ => oldies}/thefirst.lua | 0 .../181015/{ => oldies}/web_led_onoff.lua | 0 .../181015/{ => oldies}/wifi_ap_start.lua | 0 Workshop/181015/{ => oldies}/wifi_ap_stop.lua | 0 .../181015/{ => oldies}/wifi_cli_conf.lua | 0 .../181015/{ => oldies}/wifi_cli_start.lua | 0 .../181015/{ => oldies}/wifi_cli_stop.lua | 0 .../181015/{ => oldies}/wifi_cnf_start.lua | 0 .../181015/{ => oldies}/wifi_cnf_stop.lua | 0 Workshop/181015/{ => oldies}/wifi_get_ip.lua | 0 Workshop/181015/{ => oldies}/wifi_info.lua | 0 Workshop/181015/{ => oldies}/wifi_off.lua | 0 Workshop/181015/{ => oldies}/wifi_start.lua | 0 Workshop/181015/web_get.lua | 77 ------------------- Workshop/181015/web_html.lua | 24 ------ Workshop/181015/web_srv.lua | 39 ---------- Workshop/181015/web_srv/a_start_boot.lua | 6 +- Workshop/181015/web_srv/flash_led_xfois.lua | 6 +- Workshop/181015/web_srv/initz.lua | 6 +- Workshop/181015/web_srv/web_get.lua | 3 +- Workshop/181015/web_srv/web_html.lua | 7 +- Workshop/181015/web_srv/web_srv.lua | 28 +++---- Workshop/181015/web_srv/wifi_cli_conf.lua | 4 +- Workshop/181015/web_srv/wifi_get_ip.lua | 6 +- rtelnet.sh | 7 +- 50 files changed, 156 insertions(+), 263 deletions(-) rename Workshop/181015/{blink_led_ko.lua => blink_led0_ko.lua} (100%) rename Workshop/181015/{ => oldies}/btn_led.lua (100%) rename Workshop/181015/{ => oldies}/cat.lua (100%) rename Workshop/181015/{ => oldies}/dir.lua (100%) rename Workshop/181015/{hello_world => oldies}/flash_led_xfois.lua (68%) rename Workshop/181015/{ => oldies}/initz.lua (100%) create mode 100644 Workshop/181015/oldies/rm_files.lua rename Workshop/181015/{ => oldies}/start_boot.lua (100%) rename Workshop/181015/{ => oldies}/start_job.lua (100%) rename Workshop/181015/{ => oldies}/telnet_srv.lua (100%) rename Workshop/181015/{ => oldies}/thefirst.lua (100%) rename Workshop/181015/{ => oldies}/web_led_onoff.lua (100%) rename Workshop/181015/{ => oldies}/wifi_ap_start.lua (100%) rename Workshop/181015/{ => oldies}/wifi_ap_stop.lua (100%) rename Workshop/181015/{ => oldies}/wifi_cli_conf.lua (100%) rename Workshop/181015/{ => oldies}/wifi_cli_start.lua (100%) rename Workshop/181015/{ => oldies}/wifi_cli_stop.lua (100%) rename Workshop/181015/{ => oldies}/wifi_cnf_start.lua (100%) rename Workshop/181015/{ => oldies}/wifi_cnf_stop.lua (100%) rename Workshop/181015/{ => oldies}/wifi_get_ip.lua (100%) rename Workshop/181015/{ => oldies}/wifi_info.lua (100%) rename Workshop/181015/{ => oldies}/wifi_off.lua (100%) rename Workshop/181015/{ => oldies}/wifi_start.lua (100%) delete mode 100644 Workshop/181015/web_get.lua delete mode 100644 Workshop/181015/web_html.lua delete mode 100644 Workshop/181015/web_srv.lua mode change 100755 => 100644 rtelnet.sh diff --git a/Workshop/181015/blink_led_ko.lua b/Workshop/181015/blink_led0_ko.lua similarity index 100% rename from Workshop/181015/blink_led_ko.lua rename to Workshop/181015/blink_led0_ko.lua diff --git a/Workshop/181015/blink_led1.lua b/Workshop/181015/blink_led1.lua index f5f5249..2815092 100644 --- a/Workshop/181015/blink_led1.lua +++ b/Workshop/181015/blink_led1.lua @@ -1,22 +1,17 @@ --- programme pour faire clignoter une LED avec un rapport on/off ---zf20180717.1118 +-- programme pour faire clignoter une LED version simplifiée + +print("\n blink_led1.lua zf200302.2243 \n") zLED=0 -zTm_On_LED = 500 --> en ms -zTm_Off_LED = 500 --> en ms -zFlag_LED = 0 - -function blink_LED () - if zFlag_LED==gpio.LOW then - zFlag_LED=gpio.HIGH - tmr.alarm(ztmr_LED, zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED) - else - zFlag_LED=gpio.LOW - tmr.alarm(ztmr_LED, zTm_On_LED, tmr.ALARM_SINGLE, blink_LED) - end - gpio.write(zLED, zFlag_LED) -end - gpio.mode(zLED, gpio.OUTPUT) ztmr_LED = tmr.create() -blink_LED () +value = true + +ztmr_LED:alarm(100, tmr.ALARM_AUTO, function () + if value then + gpio.write(zLED, gpio.HIGH) + else + gpio.write(zLED, gpio.LOW) + end + value = not value +end) diff --git a/Workshop/181015/blink_led2.lua b/Workshop/181015/blink_led2.lua index 7115b63..677015a 100644 --- a/Workshop/181015/blink_led2.lua +++ b/Workshop/181015/blink_led2.lua @@ -1,18 +1,23 @@ --- programme pour faire clignoter une LED version simplifiée +-- programme pour faire clignoter une LED avec un rapport on/off -print("\n blink_led2.lua zf181019.2000 \n") +print("\n blink_led2.lua zf200302.2243 \n") zLED=0 +zTm_On_LED = 50 --> en ms +zTm_Off_LED = 500 --> en ms +zFlag_LED = 0 + +function blink_LED () + if zFlag_LED==gpio.LOW then + zFlag_LED=gpio.HIGH + ztmr_LED:alarm(zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED) + else + zFlag_LED=gpio.LOW + ztmr_LED:alarm(zTm_On_LED, tmr.ALARM_SINGLE, blink_LED) + end + gpio.write(zLED, zFlag_LED) +end + gpio.mode(zLED, gpio.OUTPUT) ztmr_LED = tmr.create() -value = true - -tmr.alarm(ztmr_LED, 100, tmr.ALARM_AUTO, function () - if value then - gpio.write(zLED, gpio.HIGH) - else - gpio.write(zLED, gpio.LOW) - end - value = not value - -end) +blink_LED () diff --git a/Workshop/181015/btn_led_remote/btn/btn_led.lua b/Workshop/181015/btn_led_remote/btn/btn_led.lua index 5b7b9f4..515cf59 100644 --- a/Workshop/181015/btn_led_remote/btn/btn_led.lua +++ b/Workshop/181015/btn_led_remote/btn/btn_led.lua @@ -1,7 +1,7 @@ -- Programme qui allume la led bleue quand on appuie le bouton flash -- zf181011.1749 -print("\n btn_led.lua zf190808.1540 \n") +print("\n btn_led.lua zf200302.2356 \n") zledbleue=0 --led bleue @@ -18,7 +18,7 @@ function zbtn() gpio.write(zledbleue, gpio.HIGH) end print("btn_led: "..zled_state) --- disp_send() + disp_send() end gpio.trig(zswitch, "both", zbtn) diff --git a/Workshop/181015/btn_led_remote/btn/flash_led_xfois.lua b/Workshop/181015/btn_led_remote/btn/flash_led_xfois.lua index fc38772..b6ee0a8 100644 --- a/Workshop/181015/btn_led_remote/btn/flash_led_xfois.lua +++ b/Workshop/181015/btn_led_remote/btn/flash_led_xfois.lua @@ -1,5 +1,5 @@ -- programme pour faire clignoter x fois une LED avec un rapport on/off -print("\n flash_led_xfois.lua zf181018.1428 \n") +print("\n flash_led_xfois.lua zf200302.2316 \n") zLED=0 zTm_On_LED = 50 --> en ms @@ -16,11 +16,11 @@ function blink_LED () else if gpio.read(zLED)==gpio.HIGH then gpio.write(zLED, gpio.LOW) - tmr.alarm(ztmr_LED, zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED) + ztmr_LED:alarm(zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED) else gpio.write(zLED, gpio.HIGH) nbfois = nbfois+1 - tmr.alarm(ztmr_LED, zTm_On_LED, tmr.ALARM_SINGLE, blink_LED) + ztmr_LED:alarm(zTm_On_LED, tmr.ALARM_SINGLE, blink_LED) end end end diff --git a/Workshop/181015/btn_led_remote/btn/start_boot.lua b/Workshop/181015/btn_led_remote/btn/start_boot.lua index c717cf9..4d2adea 100644 --- a/Workshop/181015/btn_led_remote/btn/start_boot.lua +++ b/Workshop/181015/btn_led_remote/btn/start_boot.lua @@ -1,10 +1,10 @@ -- Scripts à charger au moment du boot afin de pouvoir travailler avec le robot à distance -print("\n start_boot.lua zf1908.1539 \n") +print("\n start_boot.lua zf200302.2351 \n") ---dofile("wifi_ap_stop.lua") ---dofile("wifi_cli_conf.lua") ---dofile("wifi_cli_start.lua") ---dofile("web_cli.lua") +dofile("wifi_ap_stop.lua") +dofile("wifi_cli_conf.lua") +dofile("wifi_cli_start.lua") +dofile("web_cli.lua") dofile("btn_led.lua") ---dofile("flash_led_xfois.lua") +dofile("flash_led_xfois.lua") diff --git a/Workshop/181015/btn_led_remote/btn/web_cli.lua b/Workshop/181015/btn_led_remote/btn/web_cli.lua index 0efead7..f629537 100644 --- a/Workshop/181015/btn_led_remote/btn/web_cli.lua +++ b/Workshop/181015/btn_led_remote/btn/web_cli.lua @@ -1,10 +1,10 @@ -- Petit script pour envoyer quelque chose sur un serveur WEB -print("\n web_cli.lua zf190808.1605 \n") +print("\n web_cli.lua zf200302.2357 \n") function disp_send() -- http.get("http://192.168.4.1/?line1="..zlength.."m", nil, function(code, data) print("web_cli: "..zled_state) - http.get("http://192.168.43.158/?pin="..zled_state, nil, function(code, data) + http.get("http://192.168.4.1/?pin="..zled_state, nil, function(code, data) if (code < 0) then print("HTTP request failed") else diff --git a/Workshop/181015/btn_led_remote/btn/wifi_cli_conf.lua b/Workshop/181015/btn_led_remote/btn/wifi_cli_conf.lua index 9f1326e..14b0c04 100644 --- a/Workshop/181015/btn_led_remote/btn/wifi_cli_conf.lua +++ b/Workshop/181015/btn_led_remote/btn/wifi_cli_conf.lua @@ -1,5 +1,4 @@ -- Petit script pour configurer le client WIFI du NodeMCU -print("\n wifi_cli_conf.lua zf190808.1559 \n") - -wifi.sta.config{ssid="3g-s7", pwd="12234567", save=true} +print("\n wifi_cli_conf.lua zf200302.2353 \n") +wifi.sta.config{ssid="NodeMCU btn 3a:2b:78:04:2d:2d", pwd="12345678", save=true} diff --git a/Workshop/181015/btn_led_remote/btn/wifi_get_ip.lua b/Workshop/181015/btn_led_remote/btn/wifi_get_ip.lua index d166aed..c66081c 100644 --- a/Workshop/181015/btn_led_remote/btn/wifi_get_ip.lua +++ b/Workshop/181015/btn_led_remote/btn/wifi_get_ip.lua @@ -1,12 +1,13 @@ -- Petit script pour obtenir l'adresse IP du NodeMCU connecté sur un AP Wifi -print("\n wifi_get_ip.lua zf190808.1600 \n") +print("\n wifi_get_ip.lua zf200303.0000 \n") wifitimer1=tmr.create() wifitimer1:alarm(1000, tmr.ALARM_AUTO , function() if wifi.sta.getip() == nil then print("Connecting to AP...") else - wifitimer1:stop() + wifitimer1:unregister() dofile("wifi_info.lua") + dofile("flash_led_xfois.lua") end end) diff --git a/Workshop/181015/btn_led_remote/led/flash_led_xfois.lua b/Workshop/181015/btn_led_remote/led/flash_led_xfois.lua index fc38772..b6ee0a8 100644 --- a/Workshop/181015/btn_led_remote/led/flash_led_xfois.lua +++ b/Workshop/181015/btn_led_remote/led/flash_led_xfois.lua @@ -1,5 +1,5 @@ -- programme pour faire clignoter x fois une LED avec un rapport on/off -print("\n flash_led_xfois.lua zf181018.1428 \n") +print("\n flash_led_xfois.lua zf200302.2316 \n") zLED=0 zTm_On_LED = 50 --> en ms @@ -16,11 +16,11 @@ function blink_LED () else if gpio.read(zLED)==gpio.HIGH then gpio.write(zLED, gpio.LOW) - tmr.alarm(ztmr_LED, zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED) + ztmr_LED:alarm(zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED) else gpio.write(zLED, gpio.HIGH) nbfois = nbfois+1 - tmr.alarm(ztmr_LED, zTm_On_LED, tmr.ALARM_SINGLE, blink_LED) + ztmr_LED:alarm(zTm_On_LED, tmr.ALARM_SINGLE, blink_LED) end end end diff --git a/Workshop/181015/btn_led_remote/led/wifi_cli_conf.lua b/Workshop/181015/btn_led_remote/led/wifi_cli_conf.lua index 9f1326e..74be53b 100644 --- a/Workshop/181015/btn_led_remote/led/wifi_cli_conf.lua +++ b/Workshop/181015/btn_led_remote/led/wifi_cli_conf.lua @@ -1,5 +1,4 @@ -- Petit script pour configurer le client WIFI du NodeMCU -print("\n wifi_cli_conf.lua zf190808.1559 \n") - -wifi.sta.config{ssid="3g-s7", pwd="12234567", save=true} +print("\n wifi_cli_conf.lua zf200302.2300 \n") +wifi.sta.config{ssid="apzuzu6", pwd="12234567", save=true} diff --git a/Workshop/181015/btn_led_remote/led/wifi_get_ip.lua b/Workshop/181015/btn_led_remote/led/wifi_get_ip.lua index d166aed..2f584f4 100644 --- a/Workshop/181015/btn_led_remote/led/wifi_get_ip.lua +++ b/Workshop/181015/btn_led_remote/led/wifi_get_ip.lua @@ -1,12 +1,12 @@ -- Petit script pour obtenir l'adresse IP du NodeMCU connecté sur un AP Wifi -print("\n wifi_get_ip.lua zf190808.1600 \n") +print("\n wifi_get_ip.lua zf200302.2258 \n") wifitimer1=tmr.create() wifitimer1:alarm(1000, tmr.ALARM_AUTO , function() if wifi.sta.getip() == nil then print("Connecting to AP...") else - wifitimer1:stop() + wifitimer1:unregister() dofile("wifi_info.lua") end end) diff --git a/Workshop/181015/btn_led_remote/led/wifi_info.lua b/Workshop/181015/btn_led_remote/led/wifi_info.lua index 800b8d4..7c0daa7 100644 --- a/Workshop/181015/btn_led_remote/led/wifi_info.lua +++ b/Workshop/181015/btn_led_remote/led/wifi_info.lua @@ -1,28 +1,45 @@ -- Petit script pour afficher les infos actuel du WIFI -print("\n wifi_info.lua zf180824.2000 \n") +print("\n wifi_info.lua zf200106.1803 \n") -local zmodewifi=wifi.getmode() - -if zmodewifi == wifi.NULLMODE then - print("WIFI OFF") -elseif zmodewifi == wifi.STATION then - print("WIFI mode CLI") - print("Connected IP:\n",wifi.sta.getip()) - do +function wifi_info() + local zmodewifi=wifi.getmode() + + --wifi.NULLMODE, wifi.STATION, wifi.SOFTAP, wifi.STATIONAP + + if zmodewifi == wifi.NULLMODE then + print("WIFI OFF") + elseif zmodewifi == wifi.STATION then + print("WIFI mode CLI") + print("Connected IP:\n",wifi.sta.getip()) local sta_config=wifi.sta.getconfig(true) - print(string.format("Current client config:\n\tssid:\"%s\"\tpassword:\"%s\"\n\tbssid:\"%s\"\tbssid_set:%s", sta_config.ssid, sta_config.pwd, sta_config.bssid, (sta_config.bssid_set and "true" or "false"))) - end -elseif zmodewifi == wifi.SOFTAP then - print("WIFI mode AP") - print("AP MAC:\n\t"..wifi.ap.getmac()) - print("AP IP:\n\t"..wifi.ap.getip()) -elseif zmodewifi == wifi.STATIONAP then - print("WIFI mode CLI+AP") - print("Connected IP:\n",wifi.sta.getip()) - do + print("Current client config:") + print("\tssid:", sta_config.ssid) + print("\tpassword:", sta_config.pwd) + print("\tbssid:", sta_config.bssid) + elseif zmodewifi == wifi.SOFTAP then + print("WIFI mode AP\n") + print("AP IP: ", wifi.ap.getip()) + print("Current AP config:") + local ap_config=wifi.ap.getconfig(true) + print("\tssid:", ap_config.ssid) + print("\tpassword:", ap_config.pwd) + print("\tbssid:", wifi.ap.getmac()) + elseif zmodewifi == wifi.STATIONAP then + print("WIFI mode CLI+AP\n") + print("CLIENT IP:\n",wifi.sta.getip()) local sta_config=wifi.sta.getconfig(true) - print(string.format("Current client config:\n\tssid:\"%s\"\tpassword:\"%s\"\n\tbssid:\"%s\"\tbssid_set:%s", sta_config.ssid, sta_config.pwd, sta_config.bssid, (sta_config.bssid_set and "true" or "false"))) + print("Current CLIENT config:") + print("\tssid:", sta_config.ssid) + print("\tpassword:", sta_config.pwd) + print("\tbssid:", sta_config.bssid.."\n") + print("AP IP: ", wifi.ap.getip()) + print("Current AP config:") + local ap_config=wifi.ap.getconfig(true) + print("\tssid:", ap_config.ssid) + print("\tpassword:", ap_config.pwd) + print("\tbssid:", wifi.ap.getmac()) end - print("AP MAC: "..wifi.ap.getmac()) - print("AP IP: "..wifi.ap.getip()) + wifi_info=nil end +wifi_info() + diff --git a/Workshop/181015/flash_led_xfois.lua b/Workshop/181015/flash_led_xfois.lua index fc38772..b6ee0a8 100644 --- a/Workshop/181015/flash_led_xfois.lua +++ b/Workshop/181015/flash_led_xfois.lua @@ -1,5 +1,5 @@ -- programme pour faire clignoter x fois une LED avec un rapport on/off -print("\n flash_led_xfois.lua zf181018.1428 \n") +print("\n flash_led_xfois.lua zf200302.2316 \n") zLED=0 zTm_On_LED = 50 --> en ms @@ -16,11 +16,11 @@ function blink_LED () else if gpio.read(zLED)==gpio.HIGH then gpio.write(zLED, gpio.LOW) - tmr.alarm(ztmr_LED, zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED) + ztmr_LED:alarm(zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED) else gpio.write(zLED, gpio.HIGH) nbfois = nbfois+1 - tmr.alarm(ztmr_LED, zTm_On_LED, tmr.ALARM_SINGLE, blink_LED) + ztmr_LED:alarm(zTm_On_LED, tmr.ALARM_SINGLE, blink_LED) end end end diff --git a/Workshop/181015/hello_world/blink_led1.lua b/Workshop/181015/hello_world/blink_led1.lua index cbee59a..f6cea47 100644 --- a/Workshop/181015/hello_world/blink_led1.lua +++ b/Workshop/181015/hello_world/blink_led1.lua @@ -1,6 +1,6 @@ -- programme pour faire clignoter une LED avec un rapport on/off -print("\n blink_led1.lua zf190808.1134 \n") +print("\n blink_led1.lua zf200302.2243 \n") zLED=0 zTm_On_LED = 50 --> en ms diff --git a/Workshop/181015/hello_world/initz.lua b/Workshop/181015/hello_world/initz.lua index 97951ca..6a9824a 100644 --- a/Workshop/181015/hello_world/initz.lua +++ b/Workshop/181015/hello_world/initz.lua @@ -1,7 +1,7 @@ --Script de bootstrap, en appuyant sur le bouton ça démarre start_boot, -- autrement en attendant 8 secondes cela démarre start_boot -print("\n init.lua zf181017.1026\n") +print("\n init.lua zf200302.2248\n") zswitch=3 --switch flash gpio.mode(zswitch, gpio.INT, gpio.PULLUP) @@ -16,7 +16,7 @@ end gpio.trig(zswitch, "both", hvbouton) -tmr.alarm(initalarme, 8000, tmr.ALARM_SINGLE, function() +initalarme:alarm(8000, tmr.ALARM_SINGLE, function() print("\nStart\n") dofile("start_boot.lua") -- dofile("start_job.lua") diff --git a/Workshop/181015/btn_led.lua b/Workshop/181015/oldies/btn_led.lua similarity index 100% rename from Workshop/181015/btn_led.lua rename to Workshop/181015/oldies/btn_led.lua diff --git a/Workshop/181015/cat.lua b/Workshop/181015/oldies/cat.lua similarity index 100% rename from Workshop/181015/cat.lua rename to Workshop/181015/oldies/cat.lua diff --git a/Workshop/181015/dir.lua b/Workshop/181015/oldies/dir.lua similarity index 100% rename from Workshop/181015/dir.lua rename to Workshop/181015/oldies/dir.lua diff --git a/Workshop/181015/hello_world/flash_led_xfois.lua b/Workshop/181015/oldies/flash_led_xfois.lua similarity index 68% rename from Workshop/181015/hello_world/flash_led_xfois.lua rename to Workshop/181015/oldies/flash_led_xfois.lua index 76e62b2..fc38772 100644 --- a/Workshop/181015/hello_world/flash_led_xfois.lua +++ b/Workshop/181015/oldies/flash_led_xfois.lua @@ -1,5 +1,5 @@ -- programme pour faire clignoter x fois une LED avec un rapport on/off -print("\n flash_led_xfois.lua zf181105.1111 \n") +print("\n flash_led_xfois.lua zf181018.1428 \n") zLED=0 zTm_On_LED = 50 --> en ms @@ -7,7 +7,7 @@ zTm_Off_LED = 100 --> en ms nbfois = 0 gpio.write(zLED, gpio.HIGH) gpio.mode(zLED, gpio.OUTPUT) -ztmr_Flash_LED = tmr.create() +ztmr_LED = tmr.create() function blink_LED () if nbfois >= xfois then @@ -16,11 +16,11 @@ function blink_LED () else if gpio.read(zLED)==gpio.HIGH then gpio.write(zLED, gpio.LOW) - tmr.alarm(ztmr_Flash_LED, zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED) + tmr.alarm(ztmr_LED, zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED) else gpio.write(zLED, gpio.HIGH) nbfois = nbfois+1 - tmr.alarm(ztmr_Flash_LED, zTm_On_LED, tmr.ALARM_SINGLE, blink_LED) + tmr.alarm(ztmr_LED, zTm_On_LED, tmr.ALARM_SINGLE, blink_LED) end end end diff --git a/Workshop/181015/initz.lua b/Workshop/181015/oldies/initz.lua similarity index 100% rename from Workshop/181015/initz.lua rename to Workshop/181015/oldies/initz.lua diff --git a/Workshop/181015/oldies/rm_files.lua b/Workshop/181015/oldies/rm_files.lua new file mode 100644 index 0000000..81241cb --- /dev/null +++ b/Workshop/181015/oldies/rm_files.lua @@ -0,0 +1,12 @@ +-- pour effacer TOUS les fichiers qui se trouve dans la flash du NodeMCU + +print("\n rm_files.lua zf180907.1511 \n") + + +l=file.list() i=0 +for k,v in pairs(l) do + i=i+v + file.remove(k) +end +print("-------------------------------") +print("\nC'est tout effaced :-) \n") diff --git a/Workshop/181015/start_boot.lua b/Workshop/181015/oldies/start_boot.lua similarity index 100% rename from Workshop/181015/start_boot.lua rename to Workshop/181015/oldies/start_boot.lua diff --git a/Workshop/181015/start_job.lua b/Workshop/181015/oldies/start_job.lua similarity index 100% rename from Workshop/181015/start_job.lua rename to Workshop/181015/oldies/start_job.lua diff --git a/Workshop/181015/telnet_srv.lua b/Workshop/181015/oldies/telnet_srv.lua similarity index 100% rename from Workshop/181015/telnet_srv.lua rename to Workshop/181015/oldies/telnet_srv.lua diff --git a/Workshop/181015/thefirst.lua b/Workshop/181015/oldies/thefirst.lua similarity index 100% rename from Workshop/181015/thefirst.lua rename to Workshop/181015/oldies/thefirst.lua diff --git a/Workshop/181015/web_led_onoff.lua b/Workshop/181015/oldies/web_led_onoff.lua similarity index 100% rename from Workshop/181015/web_led_onoff.lua rename to Workshop/181015/oldies/web_led_onoff.lua diff --git a/Workshop/181015/wifi_ap_start.lua b/Workshop/181015/oldies/wifi_ap_start.lua similarity index 100% rename from Workshop/181015/wifi_ap_start.lua rename to Workshop/181015/oldies/wifi_ap_start.lua diff --git a/Workshop/181015/wifi_ap_stop.lua b/Workshop/181015/oldies/wifi_ap_stop.lua similarity index 100% rename from Workshop/181015/wifi_ap_stop.lua rename to Workshop/181015/oldies/wifi_ap_stop.lua diff --git a/Workshop/181015/wifi_cli_conf.lua b/Workshop/181015/oldies/wifi_cli_conf.lua similarity index 100% rename from Workshop/181015/wifi_cli_conf.lua rename to Workshop/181015/oldies/wifi_cli_conf.lua diff --git a/Workshop/181015/wifi_cli_start.lua b/Workshop/181015/oldies/wifi_cli_start.lua similarity index 100% rename from Workshop/181015/wifi_cli_start.lua rename to Workshop/181015/oldies/wifi_cli_start.lua diff --git a/Workshop/181015/wifi_cli_stop.lua b/Workshop/181015/oldies/wifi_cli_stop.lua similarity index 100% rename from Workshop/181015/wifi_cli_stop.lua rename to Workshop/181015/oldies/wifi_cli_stop.lua diff --git a/Workshop/181015/wifi_cnf_start.lua b/Workshop/181015/oldies/wifi_cnf_start.lua similarity index 100% rename from Workshop/181015/wifi_cnf_start.lua rename to Workshop/181015/oldies/wifi_cnf_start.lua diff --git a/Workshop/181015/wifi_cnf_stop.lua b/Workshop/181015/oldies/wifi_cnf_stop.lua similarity index 100% rename from Workshop/181015/wifi_cnf_stop.lua rename to Workshop/181015/oldies/wifi_cnf_stop.lua diff --git a/Workshop/181015/wifi_get_ip.lua b/Workshop/181015/oldies/wifi_get_ip.lua similarity index 100% rename from Workshop/181015/wifi_get_ip.lua rename to Workshop/181015/oldies/wifi_get_ip.lua diff --git a/Workshop/181015/wifi_info.lua b/Workshop/181015/oldies/wifi_info.lua similarity index 100% rename from Workshop/181015/wifi_info.lua rename to Workshop/181015/oldies/wifi_info.lua diff --git a/Workshop/181015/wifi_off.lua b/Workshop/181015/oldies/wifi_off.lua similarity index 100% rename from Workshop/181015/wifi_off.lua rename to Workshop/181015/oldies/wifi_off.lua diff --git a/Workshop/181015/wifi_start.lua b/Workshop/181015/oldies/wifi_start.lua similarity index 100% rename from Workshop/181015/wifi_start.lua rename to Workshop/181015/oldies/wifi_start.lua diff --git a/Workshop/181015/web_get.lua b/Workshop/181015/web_get.lua deleted file mode 100644 index 5688fa3..0000000 --- a/Workshop/181015/web_get.lua +++ /dev/null @@ -1,77 +0,0 @@ --- petit script pour la gestion du GET du serveur web - -print("\n web_get.lua hv180907.1557 \n") - -webtimer1=tmr.create() -webtimer2=tmr.create() -webtimer3=tmr.create() -webtimer4=tmr.create() - -function forward_stop() - if zauto then - tmr.alarm(webtimer3, turn_on, tmr.ALARM_SINGLE, forward) - else - tmr.alarm(webtimer3, turn_on, tmr.ALARM_SINGLE, stop) - end -end - ---Réaction des boutons -function web_get() - if (_GET.pin == "L") then - left() - forward_stop() - elseif (_GET.pin == "R") then - right() - forward_stop() - elseif (_GET.pin == "F") then - forward() - elseif (_GET.pin == "B") then - backward() - elseif (_GET.pin == "S") then - zauto=false - stop() - elseif (_GET.pin == "SL") then - zpeed=50 - set_speed() - elseif (_GET.pin == "SM") then - zpeed=70 - set_speed() - elseif (_GET.pin == "SF") then - zpeed=100 - set_speed() - elseif (_GET.pin == "A") then - tmr.alarm(webtimer1, 500, tmr.ALARM_SINGLE, function() - stop() - oled_line1="Auto..." oled_line2="" oled_line3="" oled_line4="" oled_line5="" - disp_oled() - zauto=true - tmr.alarm(webtimer1, 500, tmr.ALARM_SINGLE, start_mesure) - end) - elseif (_GET.pin == "ML") then - tmr.alarm(webtimer1, 500, tmr.ALARM_SINGLE, function() - stop() - oled_line1="Manuel..." oled_line2="" oled_line3="" oled_line4="" oled_line5="" - disp_oled() - zauto=false - end) - elseif (_GET.pin == "T1") then - tmr.alarm(webtimer1, 500, tmr.ALARM_SINGLE, function() - dofile("start_job.lua") - end) - elseif (_GET.pin == "T2") then - oled_line1="Restart..." oled_line2="" oled_line3="" oled_line4="" oled_line5="" - disp_oled() - zauto=false - tmr.alarm(webtimer1, 500, tmr.ALARM_SINGLE, node.restart) - elseif (_GET.pin == "T3") then - tmr.alarm(webtimer1, 500, tmr.ALARM_SINGLE, function() - zauto=false - zmeter=true - stop() - oled_line1="Meter..." oled_line2="" oled_line3="" oled_line4="" oled_line5="" - disp_oled() - tmr.alarm(webtimer2, 600, tmr.ALARM_AUTO, start_mesure) - end) - end -end - diff --git a/Workshop/181015/web_html.lua b/Workshop/181015/web_html.lua deleted file mode 100644 index aee01b0..0000000 --- a/Workshop/181015/web_html.lua +++ /dev/null @@ -1,24 +0,0 @@ --- petit script pour le HTML du serveur web - -print("\n web_html.lua hv180907.1542 \n") - ---Partie HTML et CSS pour la page web -function web_html() - buf = "\n" - buf = buf .. "

Contrôler le robot :

" - buf = buf .. "
\n" - buf = buf .. "
\n" - buf = buf .. "\n" - buf = buf .. "

Vitesse :

\n" - buf = buf .. "\n" - buf = buf .. "

Robot :

\n" - buf = buf .. "\n" - buf = buf .. "

Tests :

\n" - buf = buf .. "" - buf = buf .. "\n" - buf = buf .. "\n" -end diff --git a/Workshop/181015/web_srv.lua b/Workshop/181015/web_srv.lua deleted file mode 100644 index f6e611d..0000000 --- a/Workshop/181015/web_srv.lua +++ /dev/null @@ -1,39 +0,0 @@ --- petit script de serveur WEB Wifi - -print("\n web_srv.lua hv180906.1455 \n") - -dofile("web_get.lua") -dofile("web_html.lua") - -srv = net.createServer(net.TCP) -srv:listen(80, function(conn) - conn:on("receive", function(client, request) - _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP") - - --print("\n\nweb_srv") - --print("method: ",method) - --print("path: ",path) - --print("request: ",request) - --print("vars: ",vars) - - if not string.find(request, "/favicon.ico") then - --print("coucou") - if (method == nil) then - _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP") - end - _GET = {} - if (vars ~= nil) then - for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do - _GET[k] = v - print(k..": "..v) - end - end - web_get() - web_html() - --print("send html...") - client:send(buf) - buf=nil - end - end) - conn:on("sent", function(c) c:close() end) -end) diff --git a/Workshop/181015/web_srv/a_start_boot.lua b/Workshop/181015/web_srv/a_start_boot.lua index e6565b8..fbccb0b 100644 --- a/Workshop/181015/web_srv/a_start_boot.lua +++ b/Workshop/181015/web_srv/a_start_boot.lua @@ -1,9 +1,9 @@ -- Scripts à charger au moment du boot -print("\n a_start_boot.lua zf181018.1624 \n") +print("\n a_start_boot.lua zf200302.2315 \n") ---dofile("wifi_ap_stop.lua") ---dofile("wifi_cli_conf.lua") +dofile("wifi_ap_stop.lua") +dofile("wifi_cli_conf.lua") dofile("wifi_cli_start.lua") dofile("led_job.lua") diff --git a/Workshop/181015/web_srv/flash_led_xfois.lua b/Workshop/181015/web_srv/flash_led_xfois.lua index fc38772..b6ee0a8 100644 --- a/Workshop/181015/web_srv/flash_led_xfois.lua +++ b/Workshop/181015/web_srv/flash_led_xfois.lua @@ -1,5 +1,5 @@ -- programme pour faire clignoter x fois une LED avec un rapport on/off -print("\n flash_led_xfois.lua zf181018.1428 \n") +print("\n flash_led_xfois.lua zf200302.2316 \n") zLED=0 zTm_On_LED = 50 --> en ms @@ -16,11 +16,11 @@ function blink_LED () else if gpio.read(zLED)==gpio.HIGH then gpio.write(zLED, gpio.LOW) - tmr.alarm(ztmr_LED, zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED) + ztmr_LED:alarm(zTm_Off_LED, tmr.ALARM_SINGLE, blink_LED) else gpio.write(zLED, gpio.HIGH) nbfois = nbfois+1 - tmr.alarm(ztmr_LED, zTm_On_LED, tmr.ALARM_SINGLE, blink_LED) + ztmr_LED:alarm(zTm_On_LED, tmr.ALARM_SINGLE, blink_LED) end end end diff --git a/Workshop/181015/web_srv/initz.lua b/Workshop/181015/web_srv/initz.lua index feb1614..9cd88f1 100644 --- a/Workshop/181015/web_srv/initz.lua +++ b/Workshop/181015/web_srv/initz.lua @@ -1,7 +1,7 @@ --Script de bootstrap, en appuyant sur le bouton ça démarre start_boot, -- autrement en attendant 8 secondes cela démarre start_boot -print("\n init.lua zf181018.1623\n") +print("\n init.lua zf200302.2255\n") zswitch=3 --switch flash gpio.mode(zswitch, gpio.INT, gpio.PULLUP) @@ -9,14 +9,14 @@ initalarme=tmr.create() function hvbouton() gpio.trig(zswitch, "none") - tmr.unregister(initalarme) + initalarme:unregister() dofile("a_start_boot.lua") -- dofile("start_job.lua") end gpio.trig(zswitch, "both", hvbouton) -tmr.alarm(initalarme, 8000, tmr.ALARM_SINGLE, function() +initalarme:alarm(8000, tmr.ALARM_SINGLE, function() print("\nStart\n") dofile("a_start_boot.lua") -- dofile("start_job.lua") diff --git a/Workshop/181015/web_srv/web_get.lua b/Workshop/181015/web_srv/web_get.lua index d94ebf9..17bec8f 100644 --- a/Workshop/181015/web_srv/web_get.lua +++ b/Workshop/181015/web_srv/web_get.lua @@ -1,6 +1,6 @@ -- petit script pour la gestion du GET du serveur web -print("\n web_get.lua zf181019.1130 \n") +print("\n web_get.lua zf203002.2320 \n") function web_get() if (_GET.led == "on") then @@ -14,6 +14,7 @@ function web_get() blink_LED() html_home() elseif (_GET.led == "status") then + print("toto") html_status() else html_home() diff --git a/Workshop/181015/web_srv/web_html.lua b/Workshop/181015/web_srv/web_html.lua index 06d2e42..df99e75 100644 --- a/Workshop/181015/web_srv/web_html.lua +++ b/Workshop/181015/web_srv/web_html.lua @@ -1,6 +1,6 @@ -- petit script pour le HTML du serveur web -print("\n web_html.lua zf181019.1130 \n") +print("\n web_html.lua zf200302.2324 \n") --Partie HTML et CSS pour la page web function html_home() @@ -9,10 +9,13 @@ function html_home() buf = buf .. "Usage:

\n" buf = buf .. "pour allumer la LED, http://xxx/?led=on
\n" buf = buf .. "pour éteindre la LED, http://xxx/?led=off
\n" + buf = buf .. "pour éteindre la LED, http://xxx/?led=status
\n" + buf = buf .. "pour flasher la LED 6x, http://xxx/?led=flash&fois=6
\n" buf = buf .. "" end -function html_status() +function html_status() + print("tutu") buf = "\n" buf = buf .. "

Hello, this is NodeMCU. 1608

\n" buf = buf .. "Toto\n" diff --git a/Workshop/181015/web_srv/web_srv.lua b/Workshop/181015/web_srv/web_srv.lua index ca0f751..5e4e284 100644 --- a/Workshop/181015/web_srv/web_srv.lua +++ b/Workshop/181015/web_srv/web_srv.lua @@ -1,23 +1,23 @@ -- petit script de serveur WEB Wifi -print("\n web_srv.lua zf181018.1610 \n") +print("\n web_srv.lua zf200302.2323 \n") ---dofile("web_get.lua") ---dofile("web_html.lua") +dofile("web_get.lua") +dofile("web_html.lua") srv = net.createServer(net.TCP) srv:listen(80, function(conn) conn:on("receive", function(client, request) _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP") - print("\n\nweb_srv debug") - print("request: \n---\n"..request.."---") - print("method: ",method) - print("path: ",path) - print("vars: ",vars) + --print("\n\nweb_srv") + --print("method: ",method) + --print("path: ",path) + --print("request: ",request) + --print("vars: ",vars) if not string.find(request, "/favicon.ico") then - print("coucou") + --print("coucou") if (method == nil) then _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP") end @@ -28,11 +28,11 @@ srv:listen(80, function(conn) print(k..": "..v) end end - file_html=string.gsub(path, "/", "") - print("file_html: ",file_html) - - conn:send("

ESP8266
Server is working!

\n\n") - + web_get() +-- html_home() + --print("send html...") + client:send(buf) + buf=nil end end) conn:on("sent", function(c) c:close() end) diff --git a/Workshop/181015/web_srv/wifi_cli_conf.lua b/Workshop/181015/web_srv/wifi_cli_conf.lua index f01a799..74be53b 100644 --- a/Workshop/181015/web_srv/wifi_cli_conf.lua +++ b/Workshop/181015/web_srv/wifi_cli_conf.lua @@ -1,4 +1,4 @@ -- Petit script pour configurer le client WIFI du NodeMCU -print("\n wifi_cli_conf.lua zf180824.2000 \n") +print("\n wifi_cli_conf.lua zf200302.2300 \n") -wifi.sta.config{ssid="3g-s7", pwd="12234567", save=true} +wifi.sta.config{ssid="apzuzu6", pwd="12234567", save=true} diff --git a/Workshop/181015/web_srv/wifi_get_ip.lua b/Workshop/181015/web_srv/wifi_get_ip.lua index 83b6369..2f584f4 100644 --- a/Workshop/181015/web_srv/wifi_get_ip.lua +++ b/Workshop/181015/web_srv/wifi_get_ip.lua @@ -1,12 +1,12 @@ -- Petit script pour obtenir l'adresse IP du NodeMCU connecté sur un AP Wifi -print("\n wifi_get_ip.lua zf180824.2000 \n") +print("\n wifi_get_ip.lua zf200302.2258 \n") wifitimer1=tmr.create() -tmr.alarm(wifitimer1, 1000, tmr.ALARM_AUTO , function() +wifitimer1:alarm(1000, tmr.ALARM_AUTO , function() if wifi.sta.getip() == nil then print("Connecting to AP...") else - tmr.stop(wifitimer1) + wifitimer1:unregister() dofile("wifi_info.lua") end end) diff --git a/rtelnet.sh b/rtelnet.sh old mode 100755 new mode 100644 index 75a0f7e..9a0be7d --- a/rtelnet.sh +++ b/rtelnet.sh @@ -1,6 +1,7 @@ + #!/bin/bash # petit script provisoire pour se connecter sur les NodeMCU en reverse telnet -# zf200229.1546 +# zf200302.0903 #test si l'argument est vide if [ -z "$1" ] @@ -24,8 +25,8 @@ killall -9 ssh sleep 1 echo "On établit le serveur reverse telnet" -#ssh ubuntu@www.zuzutest.ml socat TCP-LISTEN:$1,reuseaddr,fork TCP-LISTEN:23000,reuseaddr,bind=127.0.0.1 & -ssh ubuntu@www.zuzutest.ml socat TCP-LISTEN:23047,reuseaddr,fork TCP-LISTEN:23000,reuseaddr,bind=127.0.0.1 & +ssh ubuntu@www.zuzutest.ml socat TCP-LISTEN:$1,reuseaddr,fork TCP-LISTEN:23000,reuseaddr,bind=127.0.0.1 & +#ssh ubuntu@www.zuzutest.ml socat TCP-LISTEN:23047,reuseaddr,fork TCP-LISTEN:23000,reuseaddr,bind=127.0.0.1 & watch -n 1 'ssh ubuntu@www.zuzutest.ml netstat -nat |grep 230' sleep 1