Pārlūkot izejas kodu

refactor hostname

moononournation 7 gadi atpakaļ
vecāks
revīzija
0b24e8231a
2 mainītis faili ar 4 papildinājumiem un 3 dzēšanām
  1. 2 1
      bin/config.lua
  2. 2 2
      bin/init.lua

+ 2 - 1
bin/config.lua

@@ -3,6 +3,8 @@
 
 conf = {}
 
+conf.hostname = "NODEMCU-WEBIDE" -- DNS host name send to DHCP server (don't use underscore)
+
 -- Basic Authentication Conf
 conf.auth = {}
 conf.auth.enabled = true
@@ -18,7 +20,6 @@ conf.wifi = {}
 conf.wifi.mode = wifi.SOFTAP -- default: SOFTAP (avoid try to connect an invalid AP)
 
 -- STATION config
---conf.wifi.stahostname = "NODEMCU-WEBIDE" -- DNS host name send to DHCP server (don't use underscore)
 --conf.wifi.stassid = "YourSSID" -- Name of the WiFi network you want to join
 --conf.wifi.stapwd = "PleaseInputYourPasswordHere" -- Password for the WiFi network
 

+ 2 - 2
bin/init.lua

@@ -22,7 +22,7 @@ if (conf.wifi.mode == wifi.SOFTAP) or (conf.wifi.mode == wifi.STATIONAP) then
 end
 if (conf.wifi.mode == wifi.STATION) or (conf.wifi.mode == wifi.STATIONAP) then
     print('Client MAC: ', wifi.sta.getmac())
-    wifi.sta.sethostname(conf.wifi.stahostname)
+    wifi.sta.sethostname(conf.hostname)
     wifi.sta.config(conf.wifi.stassid, conf.wifi.stapwd, 1)
 end
 
@@ -92,7 +92,7 @@ if (wifi.getmode() == wifi.STATION) or (wifi.getmode() == wifi.STATIONAP) then
              print('Failed to connect to WiFi Access Point.')
           else
              print('IP: ',ip)
-             mdns.register(conf.wifi.stahostname, { description="NodeMCU WebIDE", service="http", port=80, location='In your ESP board' })
+             mdns.register(conf.hostname, { description="NodeMCU WebIDE", service="http", port=80, location='In your ESP board' })
           end
           tmr.stop(0)
           joinCounter = nil