Super bien nettoyé mon workshop :-)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 ()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
12
Workshop/181015/oldies/rm_files.lua
Normal file
12
Workshop/181015/oldies/rm_files.lua
Normal file
@@ -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")
|
||||
@@ -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
|
||||
|
||||
@@ -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 = "<!DOCTYPE html><html><body><meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>\n"
|
||||
buf = buf .. "<h1>Contrôler le robot : </h1>"
|
||||
buf = buf .. "<a href='?pin=F'><button id='bf'>F</button></a><br>\n"
|
||||
buf = buf .. "<a href='?pin=L'><button id='bl'>L</button></a><a href='?pin=S'><button id='bs'>S</button></a><a href='?pin=R'><button id='br'>R</button></a></br>\n"
|
||||
buf = buf .. "<a href='?pin=B'><button id='bb'>B</button></a>\n"
|
||||
buf = buf .. "<h1> Vitesse : </h1>\n"
|
||||
buf = buf .. "<a href='?pin=SL'><button id='bsl'>Low</button></a><a href='?pin=SM'><button id='bsm'>Mid</button></a><a href='?pin=SF'><button id='bsf'>Fast</button></a>\n"
|
||||
buf = buf .. "<h1> Robot : </h1>\n"
|
||||
buf = buf .. "<a href='?pin=A'><button id='ba'>A</button></a><a href='?pin=ML'><button id='bml'>ML</button></a>\n"
|
||||
buf = buf .. "<h1> Tests : </h1>\n"
|
||||
buf = buf .. "<a href='?pin=T1'><button id='bt1'>Start</button></a><a href='?pin=T2'><button id='bt2'>Reboot</button></a>"
|
||||
buf = buf .. "<a href='?pin=T3'><button id='bt3'>T3</button></a><a href='?pin=T4'><button id='bt4'>T4</button></a>\n"
|
||||
buf = buf .. "<style>\n"
|
||||
buf = buf .. "#bf, #bb, #bl, #br, #bs, #bsl, #bsm, #bsf, #ba, #bml, #bt1, #bt2, #bt3, #bt4{font-size:10px; position:relative; height:50px; width:50px;}\n"
|
||||
buf = buf .. "#bf, #bb {left:50px;}\n"
|
||||
buf = buf .. "h1 {font-size:15px;}\n"
|
||||
buf = buf .. "</style>\n"
|
||||
end
|
||||
@@ -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)
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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: <br><br>\n"
|
||||
buf = buf .. "pour allumer la LED, http://xxx/?led=on<br>\n"
|
||||
buf = buf .. "pour éteindre la LED, http://xxx/?led=off<br>\n"
|
||||
buf = buf .. "pour éteindre la LED, http://xxx/?led=status<br>\n"
|
||||
buf = buf .. "pour flasher la LED 6x, http://xxx/?led=flash&fois=6<br>\n"
|
||||
buf = buf .. "</body></html>"
|
||||
end
|
||||
|
||||
function html_status()
|
||||
function html_status()
|
||||
print("tutu")
|
||||
buf = "<!DOCTYPE html><html><body><meta charset='utf-8' name='viewport' content='width=device-width, initial-scale=1.0'>\n"
|
||||
buf = buf .. "<h1>Hello, this is NodeMCU. 1608 </h1>\n"
|
||||
buf = buf .. "Toto\n"
|
||||
|
||||
@@ -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("<h1> ESP8266<BR>Server is working!</h1>\n\n")
|
||||
|
||||
web_get()
|
||||
-- html_home()
|
||||
--print("send html...")
|
||||
client:send(buf)
|
||||
buf=nil
|
||||
end
|
||||
end)
|
||||
conn:on("sent", function(c) c:close() end)
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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)
|
||||
|
||||
7
rtelnet.sh
Executable file → Normal file
7
rtelnet.sh
Executable file → Normal file
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user