diff --git a/IR/ir_receive.lua b/IR/ir_receive.lua new file mode 100644 index 0000000..0521fff --- /dev/null +++ b/IR/ir_receive.lua @@ -0,0 +1,92 @@ +-- Script pour la gestion du récepteur IR à 38kHz (LED, infrared, infrarouge) +-- permet la réception d'un code (4bits seulement) avec le protocole zIR, protocole de mon invention ;-) +-- exprès pas standard afin de ne pas être parasité par les autres sources IR ! + +print("\n ir_receive.lua zf180918.1906 \n") + +pin_hp = 8 +gpio.mode(pin_hp,gpio.OUTPUT) +gpio.write(pin_hp,gpio.LOW) + +pin_ir_receive = 7 +gpio.mode(pin_ir_receive, gpio.INT, gpio.PULLUP) + +Mark_Coeff = 0.5 +-- en mS/uS +Mark_Start = 3 *Mark_Coeff *1000 +Mark_Bit1 = 2 *Mark_Coeff *1000 +Mark_Bit0 = 1 *Mark_Coeff *1000 +Mark_Space = 0.5 *Mark_Coeff *1000 + +function detect_start_begin() + t_start_begin = tmr.now() + gpio.trig(pin_ir_receive,"up",detect_start_end) +end + +function detect_start_end() + t_start_len = tmr.now()-t_start_begin + if t_start_len >= Mark_Start*0.8 and t_start_len <= Mark_Start*1.2 then + ir_code = 0 num_bit = 0 + print("stxfir") + gpio.trig(pin_ir_receive,"down",detect_bit_begin) + else + gpio.trig(pin_ir_receive,"none") + end +end + +function detect_bit_begin() + t_bit_begin = tmr.now() + gpio.trig(pin_ir_receive,"up",detect_bit_end) +end + +function detect_bitt_end() + bit_ok = flase + t_bit_len = tmr.now()-t_bit_begin + if t_bit_len >= Mark_Bit1*0.8 and t_bit_len <= Mark_Bit1*1.2 then + ir_code = ir_code+(1+num_bit)^2 + bit_ok = true + elseif t_bit_len >= Mark_Bit0*0.8 and t_bit_len <= Mark_Bit0*1.2 then + bit_ok = true + end + if bit_ok = true then + if num_bit <= 3 then + num_bit = num_bit+1 + gpio.trig(pin_ir_receive,"down",detect_bit_begin) + else + print("code reçu: "..ir_code) + gpio.trig(pin_ir_receive,"down",detect_start_begin) + end + else + ir_code = 200 + gpio.trig(pin_ir_receive,"none") + print("code error") + end +end + +gpio.trig(pin_ir_receive,"down",detect_start_begin) + + + +--[[ +i=1 j=i + +function pulse_detected() +-- gpio.write(pin_hp,gpio.HIGH) + --tmr.delay(500) + i=i+1 +-- gpio.write(pin_hp,gpio.LOW) +end + + +ir_receive_tmr1=tmr.create() +tmr.alarm(ir_receive_tmr1, 500, tmr.ALARM_AUTO, function() + if i~=j then + gpio.write(pin_hp,gpio.HIGH) + print(i) + j=i + gpio.write(pin_hp,gpio.LOW) + end +end) +]] + + diff --git a/IR/ir_send.lua b/IR/ir_send.lua index 852b4c8..513207b 100644 --- a/IR/ir_send.lua +++ b/IR/ir_send.lua @@ -1,10 +1,10 @@ -- Script pour la gestion de l'émetteur IR à 38kHz (LED, infrared, infrarouge) --- permet l'envoi d'un code avec le protocole zIR, protocole de mon invention ;-) +-- permet l'envoi d'un code (4bits seulement) avec le protocole zIR, protocole de mon invention ;-) -- exprès pas standard afin de ne pas être parasité par les autres sources IR ! -- ATTENTION, on utilise ici l'astuce du gpio.serout pour faire la pulse de 26uS (38kHz), -- car on n'arrive pas avec le gpio.write à faire une pulse plus courte que 400uS -print("\n ir_send.lua zf180916.1706 \n") +print("\n ir_send.lua zf180918.1826 \n") pin_ir_send = 7 gpio.mode(pin_ir_send,gpio.OUTPUT) @@ -13,9 +13,9 @@ gpio.write(pin_ir_send,gpio.HIGH) Mark_Coeff = 0.5 -- en mS/uS Mark_Start = 3 *Mark_Coeff *1000 -Mark_Bit1 = 1 *Mark_Coeff *1000 -Mark_Bit0 = 2 *Mark_Coeff *1000 -Mark_Space = 1 *Mark_Coeff *1000 +Mark_Bit1 = 2 *Mark_Coeff *1000 +Mark_Bit0 = 1 *Mark_Coeff *1000 +Mark_Space = 0.5 *Mark_Coeff *1000 -- envoi une série de pulses à 38kHz de durée zduration en uS function pulse_ir(zduration) diff --git a/IR/ir_receive1.lua b/IR/oldies/ir_receive1.lua similarity index 100% rename from IR/ir_receive1.lua rename to IR/oldies/ir_receive1.lua diff --git a/IR/ir_receive2.lua b/IR/oldies/ir_receive2.lua similarity index 100% rename from IR/ir_receive2.lua rename to IR/oldies/ir_receive2.lua diff --git a/Workshop/181004/blink_led1.lua b/Workshop/181004/blink_led1.lua new file mode 100644 index 0000000..f5f5249 --- /dev/null +++ b/Workshop/181004/blink_led1.lua @@ -0,0 +1,22 @@ +-- programme pour faire clignoter une LED avec un rapport on/off +--zf20180717.1118 + +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 () diff --git a/Workshop/181004/blink_led_ko.lua b/Workshop/181004/blink_led_ko.lua new file mode 100644 index 0000000..fe0c946 --- /dev/null +++ b/Workshop/181004/blink_led_ko.lua @@ -0,0 +1,14 @@ +-- Exemple de programme à ne PAS faire sur NodeMCU Lua script +-- programme pour faire clignoter une LED avec un rapport on/off +--zf20181004.1430 + +zLED=0 +gpio.mode(zLED, gpio.OUTPUT) + +while true do + gpio.write(zLED, 0) + tmr.delay(1000*500) + gpio.write(zLED, 1) + tmr.delay(1000*500) +end + diff --git a/Workshop/181004/btn_led.lua b/Workshop/181004/btn_led.lua new file mode 100644 index 0000000..d61af6b --- /dev/null +++ b/Workshop/181004/btn_led.lua @@ -0,0 +1,17 @@ +-- Programme qui allume la led bleue quand on appuie le bouton flash +-- hv180711.1125 + +zledbleue=0 --led bleue +zswitch=3--switch flash + +gpio.mode(zswitch, gpio.INT, gpio.PULLUP) + +function bouton() + if gpio.read(zswitch)==0 then + gpio.write(zledbleue, gpio.LOW) + else + gpio.write(zledbleue, gpio.HIGH) + end +end + +gpio.trig(zswitch, "both", bouton) diff --git a/Workshop/181004/cat.lua b/Workshop/181004/cat.lua new file mode 100644 index 0000000..7c309b9 --- /dev/null +++ b/Workshop/181004/cat.lua @@ -0,0 +1,17 @@ +-- fonction cat() pour afficher le contenu d'un fichier dans la flash +print("\n cat.lua zf180826.1109 \n") + +function cat(zfile) + print("\n"..zfile.."\n-------------------------------") + + zfilei = file.open(zfile, "r") + i=1 + zline=file.readline() + repeat + print(i..": "..string.sub(zline,1,string.len(zline)-1)) + i=i+1 zline=file.readline() + until zline== nil + file.close(zfilei) + + print("-------------------------------") +end diff --git a/Workshop/181004/dir.lua b/Workshop/181004/dir.lua new file mode 100644 index 0000000..8bf9414 --- /dev/null +++ b/Workshop/181004/dir.lua @@ -0,0 +1,15 @@ +-- fonction dir() pour afficher les fichiers dans la flash +print("\n dir.lua zf180826.1019 \n") + +function dir() + print("\n-------------------------------") + l=file.list() i=0 + for k,v in pairs(l) do + i=i+v + print(k..string.rep(" ",19-string.len(k)).." : "..v.." bytes") + end + print("-------------------------------") + print('\nUsed: '..i..' bytes\nusage: dofile("file.lua")\n') +end + +dir() diff --git a/Workshop/181004/init.lua b/Workshop/181004/init.lua new file mode 100644 index 0000000..6d6d590 --- /dev/null +++ b/Workshop/181004/init.lua @@ -0,0 +1,22 @@ +--Programme qui démarre le robot en appuyant sur le bouton flash et le redémarre si le bouton flash est appuyer pendant 3 secondes + +print("\n init.lua hv180906.1450\n") + +zswitch=3 --switch flash +gpio.mode(zswitch, gpio.INT, gpio.PULLUP) +initalarme=tmr.create() + +function hvbouton() + gpio.trig(zswitch, "none") + tmr.unregister(initalarme) + dofile("start_boot.lua") + dofile("start_job.lua") +end + +gpio.trig(zswitch, "both", hvbouton) + +tmr.alarm(initalarme, 8000, tmr.ALARM_SINGLE, function() + print("\nStart\n") + dofile("start_boot.lua") +-- dofile("start_job.lua") +end) diff --git a/Workshop/181004/rm_files.lua b/Workshop/181004/rm_files.lua new file mode 100644 index 0000000..81241cb --- /dev/null +++ b/Workshop/181004/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/181004/start_boot.lua b/Workshop/181004/start_boot.lua new file mode 100644 index 0000000..f35e703 --- /dev/null +++ b/Workshop/181004/start_boot.lua @@ -0,0 +1,28 @@ +-- Scripts à charger au moment du boot afin de pouvoir travailler avec le robot à distance +print("\n start_boot.lua zf180907.1440 \n") + +dofile("disp_oled.lua") +oled_line1="RESET" +oled_line2="" +oled_line3="" +oled_line4="" +oled_line5="" +disp_oled() + +oled_line1="Waiting..." +oled_line2="" +oled_line3="" +oled_line4="" +oled_line5="" +disp_oled() + +--dofile("wifi_cnf_start.lua") +dofile("wifi_ap_stop.lua") +dofile("wifi_cli_start.lua") +dofile("web_srv.lua") +dofile("telnet_srv.lua") + +zpeed=50 +turn_on = 700 +zauto=false +dofile("motor.lua") diff --git a/Workshop/181004/start_job.lua b/Workshop/181004/start_job.lua new file mode 100644 index 0000000..c48dd47 --- /dev/null +++ b/Workshop/181004/start_job.lua @@ -0,0 +1,55 @@ +print("\n start_job.lua hv180907.1558 \n") + +jobtimer1=tmr.create() +jobtimer2=tmr.create() + +oled_line1="Job Start..." +oled_line2="" +oled_line3="" +oled_line4="" +oled_line5="" +disp_oled() + +oled_line1="AUTO..." +oled_line2="" +oled_line3="" +oled_line4="" +oled_line5="" +disp_oled() + +zpeed=50 +turn_on = 700 + +function return_mesure() + print(zlength) + print("RAM: "..node.heap()) + + if zauto then + if zlength < 0.20 then + backward() + tmr.alarm(jobtimer2, 200, tmr.ALARM_SINGLE, function() + if math.random(1,2) == 1 then + right() + else + left() + end + tmr.alarm(jobtimer2, turn_on, tmr.ALARM_SINGLE, forward) + end) + end + tmr.alarm(jobtimer1, 300, tmr.ALARM_SINGLE, start_mesure) + else + if zmeter then + oled_line1=zlength.." m" + oled_line2="" + oled_line3="" + oled_line4="NodeMCU: "..wifi.ap.getmac() + disp_oled() + end + end +end + +dofile("detector.lua") +zauto=true +tmr.alarm(jobtimer1, 300, tmr.ALARM_SINGLE, start_mesure) +forward() + diff --git a/Workshop/181004/telnet_srv.lua b/Workshop/181004/telnet_srv.lua new file mode 100644 index 0000000..21c8e7c --- /dev/null +++ b/Workshop/181004/telnet_srv.lua @@ -0,0 +1,43 @@ +-- a simple telnet server +print("\ntelnet_srv.lua zf180906.0904 \n") + +-- restart server if needed +if telnet_srv ~= nil then + telnet_srv:close() +end +telnet_srv = net.createServer(net.TCP, 180) + +telnet_srv:listen(23, function(socket) + local fifo = {} + local fifo_drained = true + + local function sender(c) + if #fifo > 0 then + c:send(table.remove(fifo, 1)) + else + fifo_drained = true + end + end + + local function s_output(str) + table.insert(fifo, str) + if socket ~= nil and fifo_drained then + fifo_drained = false + sender(socket) + end + end + + node.output(s_output, 0) -- re-direct output to function s_ouput. + + socket:on("receive", function(c, l) + node.input(l) -- works like pcall(loadstring(l)) but support multiple separate line + end) + socket:on("disconnection", function(c) + node.output(nil) -- un-regist the redirect output function, output goes to serial + end) + socket:on("sent", sender) + + print("Welcome to NodeMCU world.") +end) + +print("Telnet server running...\nUsage: telnet -r ip\n") diff --git a/Workshop/181004/thefirst.lua b/Workshop/181004/thefirst.lua new file mode 100644 index 0000000..e683d2f --- /dev/null +++ b/Workshop/181004/thefirst.lua @@ -0,0 +1,4 @@ +a=3 +b=4 +c=a*b +print(c) diff --git a/Workshop/181004/web_get.lua b/Workshop/181004/web_get.lua new file mode 100644 index 0000000..5688fa3 --- /dev/null +++ b/Workshop/181004/web_get.lua @@ -0,0 +1,77 @@ +-- 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/181004/web_html.lua b/Workshop/181004/web_html.lua new file mode 100644 index 0000000..aee01b0 --- /dev/null +++ b/Workshop/181004/web_html.lua @@ -0,0 +1,24 @@ +-- 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/181004/web_srv.lua b/Workshop/181004/web_srv.lua new file mode 100644 index 0000000..f6e611d --- /dev/null +++ b/Workshop/181004/web_srv.lua @@ -0,0 +1,39 @@ +-- 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/181004/wifi_ap_start.lua b/Workshop/181004/wifi_ap_start.lua new file mode 100644 index 0000000..ce3c29b --- /dev/null +++ b/Workshop/181004/wifi_ap_start.lua @@ -0,0 +1,13 @@ +-- Démarre le WIFI en mode AP +print("\n wifi_ap_start.lua zf180824.2000 \n") + +local zmodewifi=wifi.getmode() +if zmodewifi == wifi.NULLMODE then + print("WIFI mode AP only") + wifi.setmode(wifi.SOFTAP) +elseif zmodewifi == wifi.STATION then + print("WIFI mode AP+CLI") + wifi.setmode(wifi.STATIONAP) +end +wifi.ap.config({ ssid = "NodeMCU "..wifi.ap.getmac(), pwd = "12345678" }) +dofile("wifi_info.lua") diff --git a/Workshop/181004/wifi_ap_stop.lua b/Workshop/181004/wifi_ap_stop.lua new file mode 100644 index 0000000..2738627 --- /dev/null +++ b/Workshop/181004/wifi_ap_stop.lua @@ -0,0 +1,10 @@ +-- Démarre le WIFI en mode AP +print("\n wifi_ap_stop.lua zf180824.2000 \n") + +local zmodewifi=wifi.getmode() +if zmodewifi == wifi.SOFTAP then + wifi.setmode(wifi.NULLMODE) +elseif zmodewifi == wifi.STATIONAP then + wifi.setmode(wifi.STATION) +end +print("WIFI AP arrêté") diff --git a/Workshop/181004/wifi_cli_conf.lua b/Workshop/181004/wifi_cli_conf.lua new file mode 100644 index 0000000..d3cd11e --- /dev/null +++ b/Workshop/181004/wifi_cli_conf.lua @@ -0,0 +1,4 @@ +-- Petit script pour configurer le client WIFI du NodeMCU +print("\n wifi_cli_conf.lua zf180824.2000 \n") + +wifi.sta.config{ssid="Hugo", pwd="tototutu", save=true} diff --git a/Workshop/181004/wifi_cli_start.lua b/Workshop/181004/wifi_cli_start.lua new file mode 100644 index 0000000..aac8bea --- /dev/null +++ b/Workshop/181004/wifi_cli_start.lua @@ -0,0 +1,14 @@ +-- Petit script pour connecter le NodeMCU sur un AP Wifi avec l'accompte sauvé en EEPROM +print("\n wifi_cli_start.lua zf180824.2000 \n") + +local zmodewifi=wifi.getmode() +if zmodewifi == wifi.NULLMODE then + print("WIFI mode CLI only") + wifi.setmode(wifi.STATION) +elseif zmodewifi == wifi.SOFTAP then + print("WIFI mode AP+CLI") + wifi.setmode(wifi.STATIONAP) +end +wifi.sta.autoconnect(1) +wifi.sta.connect() +dofile("wifi_get_ip.lua") diff --git a/Workshop/181004/wifi_cli_stop.lua b/Workshop/181004/wifi_cli_stop.lua new file mode 100644 index 0000000..9429aa5 --- /dev/null +++ b/Workshop/181004/wifi_cli_stop.lua @@ -0,0 +1,10 @@ +-- Démarre le WIFI en mode AP +print("\n wifi_cli_stop.lua zf180824.2000 \n") + +local zmodewifi=wifi.getmode() +if zmodewifi == wifi.STATION then + wifi.setmode(wifi.NULLMODE) +elseif zmodewifi == wifi.STATIONAP then + wifi.setmode(wifi.SOFTAP) +end +print("WIFI CLI arrêté") diff --git a/Workshop/181004/wifi_cnf_start.lua b/Workshop/181004/wifi_cnf_start.lua new file mode 100644 index 0000000..975af72 --- /dev/null +++ b/Workshop/181004/wifi_cnf_start.lua @@ -0,0 +1,15 @@ +-- Petit script pour démarrer le mode configuration WIFI du NodeMCU +print("\n wifi_cnf_start.lua zf180906.1610 \n") + +print("\nwifi config http://192.168.4.1\n") +--dofile("wifi_ap_stop.lua") +--dofile("wifi_cli_stop.lua") + +srv:close() +telnet_srv:close() + +--wificnftimer1=tmr.create() +--tmr.alarm(wificnftimer1, 3000, tmr.ALARM_SINGLE, function() +print("coucou") + enduser_setup.start() +--end) diff --git a/Workshop/181004/wifi_cnf_stop.lua b/Workshop/181004/wifi_cnf_stop.lua new file mode 100644 index 0000000..88750e3 --- /dev/null +++ b/Workshop/181004/wifi_cnf_stop.lua @@ -0,0 +1,6 @@ +-- Petit script pour arrêter le mode configuration WIFI du NodeMCU +print("\n wifi_cnf_stop.lua zf180824.2000 \n") + +enduser_setup.stop() +wifi.sta.autoconnect(1) +wifi.sta.connect()-- Petit script pour arrêter le mode configuration WIFI du NodeMCU diff --git a/Workshop/181004/wifi_get_ip.lua b/Workshop/181004/wifi_get_ip.lua new file mode 100644 index 0000000..83b6369 --- /dev/null +++ b/Workshop/181004/wifi_get_ip.lua @@ -0,0 +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") + +wifitimer1=tmr.create() +tmr.alarm(wifitimer1, 1000, tmr.ALARM_AUTO , function() + if wifi.sta.getip() == nil then + print("Connecting to AP...") + else + tmr.stop(wifitimer1) + dofile("wifi_info.lua") + end +end) diff --git a/Workshop/181004/wifi_info.lua b/Workshop/181004/wifi_info.lua new file mode 100644 index 0000000..800b8d4 --- /dev/null +++ b/Workshop/181004/wifi_info.lua @@ -0,0 +1,28 @@ +-- Petit script pour afficher les infos actuel du WIFI +print("\n wifi_info.lua zf180824.2000 \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 + 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 + 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 + print("AP MAC: "..wifi.ap.getmac()) + print("AP IP: "..wifi.ap.getip()) +end diff --git a/Workshop/181004/wifi_off.lua b/Workshop/181004/wifi_off.lua new file mode 100644 index 0000000..b368e32 --- /dev/null +++ b/Workshop/181004/wifi_off.lua @@ -0,0 +1,4 @@ +-- Déconnecte le WIFI +print("\n wifi_off.lua zf180822.0959 \n") + +wifi.setmode(wifi.NULLMODE) diff --git a/Workshop/181004/wifi_start.lua b/Workshop/181004/wifi_start.lua new file mode 100644 index 0000000..47bfe11 --- /dev/null +++ b/Workshop/181004/wifi_start.lua @@ -0,0 +1,5 @@ +-- Exemple de petit script pour démarrer le WIFI +print("\n wifi_start.lua zf180824.2000 \n") + +dofile("wifi_cli_start.lua") +dofile("wifi_ap_start.lua") \ No newline at end of file