diff --git a/Workshop/181004/btn_led_remote/initz.lua b/Workshop/181004/btn_led_remote/initz.lua new file mode 100644 index 0000000..c0e1f86 --- /dev/null +++ b/Workshop/181004/btn_led_remote/initz.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/btn_led_remote/btn_led.lua b/Workshop/181004/btn_led_remote/ko/btn_led.lua similarity index 100% rename from Workshop/181004/btn_led_remote/btn_led.lua rename to Workshop/181004/btn_led_remote/ko/btn_led.lua diff --git a/Workshop/181004/btn_led_remote/web_cli.lua b/Workshop/181004/btn_led_remote/ko/web_cli.lua similarity index 100% rename from Workshop/181004/btn_led_remote/web_cli.lua rename to Workshop/181004/btn_led_remote/ko/web_cli.lua diff --git a/Workshop/181004/btn_led_remote/start_boot.lua b/Workshop/181004/btn_led_remote/start_boot.lua new file mode 100644 index 0000000..06b0f39 --- /dev/null +++ b/Workshop/181004/btn_led_remote/start_boot.lua @@ -0,0 +1,7 @@ +-- Scripts à charger au moment du boot afin de pouvoir travailler avec le robot à distance +print("\n start_boot.lua zf180907.1440 \n") + +dofile("wifi_cli_conf.lua") +dofile("wifi_cli_start.lua") +dofile("web_led_onoff.lua") + diff --git a/Workshop/181004/btn_led_remote/wifi_get_ip.lua b/Workshop/181004/btn_led_remote/wifi_get_ip.lua new file mode 100644 index 0000000..83b6369 --- /dev/null +++ b/Workshop/181004/btn_led_remote/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/btn_led_remote/wifi_info.lua b/Workshop/181004/btn_led_remote/wifi_info.lua new file mode 100644 index 0000000..800b8d4 --- /dev/null +++ b/Workshop/181004/btn_led_remote/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