- terminé les scripts pour la config du WIFI
This commit is contained in:
@@ -1,22 +1,15 @@
|
||||
-- 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
|
||||
print("\wifi_ap_start.lua zf180822.1544 \n")
|
||||
|
||||
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
|
||||
wifi.ap.config({ ssid = "NodeMCU "..wifi.ap.getmac(), pwd = "12345678" })
|
||||
dofile("wifi_info.lua")
|
||||
|
||||
|
||||
|
||||
@@ -9,18 +9,3 @@ elseif zmodewifi == wifi.STATIONAP then
|
||||
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)
|
||||
]]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Petit script pour connecter le NodeMCU sur un AP Wifi avec l'accompte sauvé en EEPROM
|
||||
print("\wifi_clidef_start.lua zf180822.1412 \n")
|
||||
print("\wifi_clidef_start.lua zf180822.1504 \n")
|
||||
|
||||
local zmodewifi=wifi.getmode()
|
||||
if zmodewifi == wifi.NULLMODE then
|
||||
@@ -8,10 +8,7 @@ if zmodewifi == wifi.NULLMODE then
|
||||
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.autoconnect(1)
|
||||
wifi.sta.connect()
|
||||
dofile("wifi_get_ip.lua")
|
||||
|
||||
|
||||
|
||||
@@ -1,26 +1,11 @@
|
||||
-- Démarre le WIFI en mode AP
|
||||
print("\wifi_ap_stop.lua zf180822.1425 \n")
|
||||
print("\wifi_cli_stop.lua zf180822.1506 \n")
|
||||
|
||||
local zmodewifi=wifi.getmode()
|
||||
if zmodewifi == wifi.STATIONAP then
|
||||
if zmodewifi == wifi.STATION then
|
||||
wifi.setmode(wifi.NULLMODE)
|
||||
elseif zmodewifi == wifi.SOFTAP then
|
||||
wifi.setmode(wifi.STATION)
|
||||
elseif zmodewifi == wifi.STATIONAP then
|
||||
wifi.setmode(wifi.SOFTAP)
|
||||
end
|
||||
print("WIFI AP arrêté")
|
||||
print("WIFI CLI 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)
|
||||
]]
|
||||
|
||||
7
Wifi/wifi_cnf_start.lua
Normal file
7
Wifi/wifi_cnf_start.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
-- Petit script pour démarrer le mode configuration WIFI du NodeMCU
|
||||
print("\wifi_cnf_start.lua zf180822.1540 \n")
|
||||
|
||||
print("\nwifi config http://192.168.4.1\n")
|
||||
dofile("wifi_get_ip.lua")
|
||||
enduser_setup.start()
|
||||
|
||||
6
Wifi/wifi_cnf_stop.lua
Normal file
6
Wifi/wifi_cnf_stop.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
-- Petit script pour arrêter le mode configuration WIFI du NodeMCU
|
||||
print("\wifi_cnf_stop.lua zf180822.1538 \n")
|
||||
|
||||
enduser_setup.stop()
|
||||
wifi.sta.autoconnect(1)
|
||||
wifi.sta.connect()
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Petit script pour obtenir l'adresse IP du NodeMCU connecté sur un AP Wifi
|
||||
print("\wifi_get_ip.lua zf180822.1422 \n")
|
||||
print("\wifi_get_ip.lua zf180822.1522 \n")
|
||||
|
||||
wifitimer1=tmr.create()
|
||||
tmr.alarm(wifitimer1, 1000, tmr.ALARM_AUTO , function()
|
||||
@@ -7,11 +7,7 @@ tmr.alarm(wifitimer1, 1000, tmr.ALARM_AUTO , function()
|
||||
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())
|
||||
dofile("wifi_info.lua")
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Petit script pour afficher les infos actuel du WIFI
|
||||
print("\wifi_info.lua zf180822.1452 \n")
|
||||
print("\wifi_info.lua zf180822.1520 \n")
|
||||
|
||||
local zmodewifi=wifi.getmode()
|
||||
|
||||
@@ -9,10 +9,10 @@ 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())
|
||||
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")))
|
||||
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")
|
||||
@@ -20,25 +20,12 @@ elseif zmodewifi == wifi.SOFTAP then
|
||||
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())
|
||||
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")))
|
||||
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)
|
||||
]]
|
||||
|
||||
7
Wifi/wifi_start.lua
Normal file
7
Wifi/wifi_start.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
-- Exemple de petit script pour démarrer le WIFI
|
||||
|
||||
print("\n wifi_start.lua zf180822.1510 \n")
|
||||
|
||||
dofile("wifi_cli_start.lua")
|
||||
dofile("wifi_ap_start.lua")
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
-- 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()
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
-- Déclenche le mode configuration WIFI
|
||||
-- zf180713.1453
|
||||
|
||||
enduser_setup.stop()
|
||||
Reference in New Issue
Block a user