summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2020-11-06 11:54:09 -0500
committerEugeniy E. Mikhailov <evgmik@gmail.com>2020-11-06 11:54:09 -0500
commitafc38622f3c4b65de7d09713dd40944e2dbc073d (patch)
tree4d0eac13c4f644257d3a08bfb92c093cfc6b247d
parenta06ac2528078b4f7c5fea25f86426d49ee731df2 (diff)
downloadnodeMCU_rf_source_lmx2487-afc38622f3c4b65de7d09713dd40944e2dbc073d.tar.gz
nodeMCU_rf_source_lmx2487-afc38622f3c4b65de7d09713dd40944e2dbc073d.zip
updated for static IP setting
-rw-r--r--wifi_config.lua47
1 files changed, 47 insertions, 0 deletions
diff --git a/wifi_config.lua b/wifi_config.lua
new file mode 100644
index 0000000..9f43d28
--- /dev/null
+++ b/wifi_config.lua
@@ -0,0 +1,47 @@
+local wifiConfig = {}
+
+-- wifi.STATION -- station: join a WiFi network
+-- wifi.SOFTAP -- access point: create a WiFi network
+-- wifi.wifi.STATIONAP -- both station and access point
+wifiConfig.mode = wifi.STATIONAP -- both station and access point
+
+wifiConfig.accessPointConfig = {}
+wifiConfig.accessPointConfig.ssid = "ESP-"..node.chipid() -- Name of the SSID you want to create
+wifiConfig.accessPointConfig.pwd = "ESP-"..node.chipid() -- WiFi password - at least 8 characters
+
+wifiConfig.accessPointIpConfig = {}
+wifiConfig.accessPointIpConfig.ip = "192.168.23.1"
+wifiConfig.accessPointIpConfig.netmask = "255.255.255.0"
+wifiConfig.accessPointIpConfig.gateway = "192.168.23.1"
+
+wifiConfig.stationPointIpConfig = {}
+wifiConfig.stationPointIpConfig.ip = "10.160.137.16" -- provided by WM IT department
+wifiConfig.stationPointIpConfig.netmask = "255.255.255.0" -- provided by WM IT department
+wifiConfig.stationPointIpConfig.gateway = "10.160.137.1" -- provided by WM IT department
+
+wifiConfig.stationPointConfig = {}
+wifiConfig.stationPointConfig.ssid = "WM-Welcome" -- Name of the WiFi network you want to join
+wifiConfig.stationPointConfig.pwd = "" -- Password for the WiFi network
+
+
+
+
+-- Tell the chip to connect to the access point
+
+wifi.setmode(wifiConfig.mode)
+print('set (mode='..wifi.getmode()..')')
+
+if (wifiConfig.mode == wifi.SOFTAP) or (wifiConfig.mode == wifi.STATIONAP) then
+ print('AP MAC: ',wifi.ap.getmac())
+ wifi.ap.config(wifiConfig.accessPointConfig)
+ wifi.ap.setip(wifiConfig.accessPointIpConfig)
+end
+if (wifiConfig.mode == wifi.STATION) or (wifiConfig.mode == wifi.STATIONAP) then
+ print('Client MAC: ',wifi.sta.getmac())
+ wifi.sta.config(wifiConfig.stationPointConfig)
+ wifi.sta.setip(wifiConfig.stationPointIpConfig)
+end
+net.dns.setdnsserver("128.239.51.1", 1)
+print('DNS Server 1: '..net.dns.getdnsserver(1))
+print('IP: '..wifi.sta.getip())
+