- complètement remanié les scripts pour le WIFI, mais ce n'est pas encore terminé
This commit is contained in:
22
Wifi/wifi_ap_start.lua
Normal file
22
Wifi/wifi_ap_start.lua
Normal file
@@ -0,0 +1,22 @@
|
||||
-- Démarre le WIFI en mode AP
|
||||
print("\wifi_ap_start.lua zf180822.1447 \n")
|
||||
|
||||
function zap_start()
|
||||
wifi.ap.config({ ssid = "NodeMCU "..wifi.ap.getmac(), pwd = "12345678" })
|
||||
end
|
||||
|
||||
local zmodewifi=wifi.getmode()
|
||||
if zmodewifi == wifi.NULLMODE then
|
||||
print("WIFI mode AP only")
|
||||
wifi.setmode(wifi.SOFTAP)
|
||||
zap_start()
|
||||
elseif zmodewifi == wifi.STATION then
|
||||
print("WIFI mode AP+CLI")
|
||||
wifi.setmode(wifi.STATIONAP)
|
||||
zap_start()
|
||||
else
|
||||
print("on ne fait rien car cela tourne déjà !")
|
||||
end
|
||||
dofile("wifi_info.lua")
|
||||
|
||||
|
||||
26
Wifi/wifi_ap_stop.lua
Normal file
26
Wifi/wifi_ap_stop.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
-- Démarre le WIFI en mode AP
|
||||
print("\wifi_ap_stop.lua zf180822.1425 \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é")
|
||||
|
||||
|
||||
|
||||
|
||||
--[[
|
||||
wifi.setmode(wifi.NULLMODE)
|
||||
print(wifi.ap.getconfig())
|
||||
print(wifi.ap.getmac())
|
||||
print(wifi.getdefaultmode())
|
||||
|
||||
print(wifi.getmode())
|
||||
print(wifi.NULLMODE, wifi.STATION, wifi.SOFTAP, wifi.STATIONAP)
|
||||
|
||||
print(wifi.getphymode())
|
||||
print(wifi.PHYMODE_B, wifi.PHYMODE_G, wifi.PHYMODE_N)
|
||||
]]
|
||||
4
Wifi/wifi_cli_conf.lua
Normal file
4
Wifi/wifi_cli_conf.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
-- Petit script pour configurer le client WIFI du NodeMCU
|
||||
print("\wifi_cli_conf.lua zf180822.1407 \n")
|
||||
|
||||
wifi.sta.config{ssid="Hugo", pwd="tototutu", save=true}
|
||||
17
Wifi/wifi_cli_start.lua
Normal file
17
Wifi/wifi_cli_start.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
-- Petit script pour connecter le NodeMCU sur un AP Wifi avec l'accompte sauvé en EEPROM
|
||||
print("\wifi_clidef_start.lua zf180822.1412 \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)
|
||||
else
|
||||
print("on ne fait rien car cela tourne déjà !")
|
||||
end
|
||||
wifi.sta.connect()
|
||||
dofile("wifi_get_ip.lua")
|
||||
|
||||
|
||||
26
Wifi/wifi_cli_stop.lua
Normal file
26
Wifi/wifi_cli_stop.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
-- Démarre le WIFI en mode AP
|
||||
print("\wifi_ap_stop.lua zf180822.1425 \n")
|
||||
|
||||
local zmodewifi=wifi.getmode()
|
||||
if zmodewifi == wifi.STATIONAP then
|
||||
wifi.setmode(wifi.NULLMODE)
|
||||
elseif zmodewifi == wifi.SOFTAP then
|
||||
wifi.setmode(wifi.STATION)
|
||||
end
|
||||
print("WIFI AP arrêté")
|
||||
|
||||
|
||||
|
||||
|
||||
--[[
|
||||
wifi.setmode(wifi.NULLMODE)
|
||||
print(wifi.ap.getconfig())
|
||||
print(wifi.ap.getmac())
|
||||
print(wifi.getdefaultmode())
|
||||
|
||||
print(wifi.getmode())
|
||||
print(wifi.NULLMODE, wifi.STATION, wifi.SOFTAP, wifi.STATIONAP)
|
||||
|
||||
print(wifi.getphymode())
|
||||
print(wifi.PHYMODE_B, wifi.PHYMODE_G, wifi.PHYMODE_N)
|
||||
]]
|
||||
17
Wifi/wifi_get_ip.lua
Normal file
17
Wifi/wifi_get_ip.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
-- Petit script pour obtenir l'adresse IP du NodeMCU connecté sur un AP Wifi
|
||||
print("\wifi_get_ip.lua zf180822.1422 \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)
|
||||
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("Connected IP:\n\t"..wifi.sta.getip())
|
||||
end
|
||||
end)
|
||||
|
||||
44
Wifi/wifi_info.lua
Normal file
44
Wifi/wifi_info.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
-- Petit script pour afficher les infos actuel du WIFI
|
||||
print("\wifi_info.lua zf180822.1452 \n")
|
||||
|
||||
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("Client IP:\n\t"..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("Client IP:\n\t"..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
|
||||
|
||||
|
||||
--[[
|
||||
wifi.setmode(wifi.NULLMODE)
|
||||
print(wifi.ap.getconfig())
|
||||
print(wifi.ap.getmac())
|
||||
print(wifi.getdefaultmode())
|
||||
|
||||
print(wifi.getmode())
|
||||
print(wifi.NULLMODE, wifi.STATION, wifi.SOFTAP, wifi.STATIONAP)
|
||||
|
||||
print(wifi.getphymode())
|
||||
print(wifi.PHYMODE_B, wifi.PHYMODE_G, wifi.PHYMODE_N)
|
||||
]]
|
||||
11
Wifi/wifi_off.lua
Normal file
11
Wifi/wifi_off.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
-- Déconnecte le WIFI
|
||||
|
||||
print("\wifi_off.lua zf180822.0959 \n")
|
||||
|
||||
wifi.setmode(wifi.NULLMODE)
|
||||
|
||||
--[[
|
||||
print(wifi.NULLMODE, wifi.STATION, wifi.SOFTAP, wifi.STATIONAP)
|
||||
print(wifi.getmode())
|
||||
]]
|
||||
|
||||
19
Wifi/wificnf_start.lua
Normal file
19
Wifi/wificnf_start.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
-- Enclenche le mode configuration WIFI
|
||||
print("\nzf180718.1107\n")
|
||||
|
||||
function get_ip()
|
||||
if wifi.sta.getip() == nil then
|
||||
print("Connecting to AP...")
|
||||
else
|
||||
tmr.stop(0)
|
||||
print("Connected! IP: ",wifi.sta.getip())
|
||||
tmr.alarm(0,3000,tmr.ALARM_SINGLE, function() node.restart() end)
|
||||
end
|
||||
end
|
||||
|
||||
wifi.sta.disconnect()
|
||||
wifi.sta.clearconfig()
|
||||
print("\nwifi config http://192.168.4.1\n")
|
||||
tmr.alarm(0, 1000, tmr.ALARM_AUTO , get_ip)
|
||||
enduser_setup.start()
|
||||
|
||||
4
Wifi/wificnf_stop.lua
Normal file
4
Wifi/wificnf_stop.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
-- Déclenche le mode configuration WIFI
|
||||
-- zf180713.1453
|
||||
|
||||
enduser_setup.stop()
|
||||
Reference in New Issue
Block a user