Only one server allowed :( go for http

This commit is contained in:
Ryan Voots 2016-05-01 17:28:10 -07:00
parent 40b2d16463
commit d06d7fb29e
3 changed files with 3 additions and 26 deletions

View file

@ -11,7 +11,7 @@ SPEED=9600
# End of user config # End of user config
###################################################################### ######################################################################
HTTP_FILES := $(wildcard http/*) HTTP_FILES := $(wildcard http/*)
LUA_FILES := init.lua telnet.lua LUA_FILES := $(wildcard *.lua)
# Print usage # Print usage
usage: usage:

View file

@ -16,10 +16,6 @@ wifiConfig.stationPointConfig = {}
wifiConfig.stationPointConfig.ssid = "Scalar24" -- Name of the WiFi network you want to join wifiConfig.stationPointConfig.ssid = "Scalar24" -- Name of the WiFi network you want to join
wifiConfig.stationPointConfig.pwd = "Fb274Gh@12G1" -- Password for the WiFi network wifiConfig.stationPointConfig.pwd = "Fb274Gh@12G1" -- Password for the WiFi network
wifiConfig.mDNS = {}
wifiConfig.mDNS.hostname = "rvoots-nameplate" -- default hostname
wifiConfig.mDNS.description = "Ryan Voot's name plate at his desk" -- what avahi-browse will describe this as
-- Tell the chip to connect to the access point -- Tell the chip to connect to the access point
wifi.setmode(wifiConfig.mode) wifi.setmode(wifiConfig.mode)
@ -59,13 +55,12 @@ end
-- Start the APs once we hit here -- Start the APs once we hit here
wifi.ap.config(wifiConfig.accessPointConfig) wifi.ap.config(wifiConfig.accessPointConfig)
wifi.sta.config(wifiConfig.stationPointConfig.ssid, wifiConfig.stationPointConfig.pwd) wifi.sta.config(wifiConfig.stationPointConfig.ssid, wifiConfig.stationPointConfig.pwd)
mdns.register(wifiConfig.mDNS.hostname, wifiConfig.mDNS)
wifiConfig = nil wifiConfig = nil
collectgarbage() collectgarbage()
-- Connect to the WiFi access point. -- Connect to the WiFi access point.
-- We run an AP, and connect to an AP. We need to start the servers early. -- We run an AP, and connect to an AP. We need to start the servers early.
dofile("telnet.lc")(23) -- dofile("telnet.lc")(23)
dofile("httpserver.lc")(80) dofile("httpserver.lc")(80)
local joinCounter = 0 local joinCounter = 0
@ -78,6 +73,7 @@ tmr.alarm(0, 3000, 1, function()
else else
if joinCounter == joinMaxAttempts then if joinCounter == joinMaxAttempts then
print('Failed to connect to WiFi Access Point.') print('Failed to connect to WiFi Access Point.')
mdns.register("rvoots-nameplate", {})
else else
print('IP: ',ip) print('IP: ',ip)
end end

View file

@ -1,19 +0,0 @@
return function(port)
-- a simple telnet server
s=net.createServer(net.TCP,180)
s:listen(port,function(c)
function s_output(str)
if(c~=nil)
then c:send(str)
end
end
node.output(s_output, 0) -- re-direct output to function s_ouput.
c:on("receive",function(c,l)
node.input(l) -- works like pcall(loadstring(l)) but support multiple separate line
end)
c:on("disconnection",function(c)
node.output(nil) -- un-regist the redirect output function, output goes to serial
end)
print("Welcome to NodeMcu world.")
end)
end