From afc38622f3c4b65de7d09713dd40944e2dbc073d Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Fri, 6 Nov 2020 11:54:09 -0500 Subject: updated for static IP setting --- wifi_config.lua | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 wifi_config.lua 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()) + -- cgit v1.2.3