Fix some typos

This commit is contained in:
Artem Pastukhov 2015-03-31 10:02:33 +03:00
parent 71058e6b44
commit 0120924403
4 changed files with 133 additions and 150 deletions

View File

@ -4,7 +4,7 @@
local function getMimeType(ext)
-- A few MIME types. Keep list short. If you need something that is missing, let's add it.
local mt = {css = "text/css", gif = "image/gif", html = "text/html", ico = "image/x-icon", jpeg = "image/jpeg", jpg = "image/jpeg", js = "application/javascript", josn="application/json", png = "image/png"}
local mt = {css = "text/css", gif = "image/gif", html = "text/html", ico = "image/x-icon", jpeg = "image/jpeg", jpg = "image/jpeg", js = "application/javascript", json = "application/json", png = "image/png"}
if mt[ext] then return mt[ext] else return "text/plain" end
end

View File

@ -73,7 +73,9 @@ return function (port)
end
)
print("nodemcu-httpserver running at http://" .. wifi.sta.getip() .. ":" .. port)
if wifi.sta.getip() then print("nodemcu-httpserver running at http://" .. wifi.sta.getip() .. ":" .. port)
else print("nodemcu-httpserver running at http://" .. wifi.ap.getip() .. ":" .. port)
end
return s
end

View File

@ -1,10 +1,18 @@
-- Tell the chip to connect to the access point
-- Tel--l the chip to connect to the access point
--wifi.setmode(wifi.STATIONAP)
wifi.setmode(wifi.STATION)
print('set mode=STATION (mode='..wifi.getmode()..')')
print('set (mode='..wifi.getmode()..')')
print('MAC: ',wifi.sta.getmac())
print('chip: ',node.chipid())
print('heap: ',node.heap())
wifi.sta.config("Internet","")
local joincounter = 0
cfg={}
cfg.ssid="ESP-"..node.chipid()
cfg.pwd="ESP-"..node.chipid()
wifi.ap.config(cfg)
cfg = nil
-- Compile server code and remove original .lua files.
-- This only happens the first time afer the .lua files are uploaded.
@ -26,13 +34,18 @@ serverFiles = nil
-- Connect to the WiFi access point. Once the device is connected,
-- you may start the HTTP server.
tmr.alarm(0, 3000, 1, function()
if wifi.sta.getip() == nil then
if wifi.sta.getip() == nil and joincounter < 5 then
print("Connecting to AP...")
joincounter = joincounter +1
else
tmr.stop(0)
print('IP: ',wifi.sta.getip())
-- print('IP: ',wifi.sta.getip())
-- Uncomment to automatically start the server in port 80
-- dofile("httpserver.lc")(80)
joincounter = nil
collectgarbage()
dofile("httpserver.lc")(80)
end
end)

View File

@ -1,32 +0,0 @@
######################################################################
# User configuration
######################################################################
# Path to nodemcu-uploader (https://github.com/kmpm/nodemcu-uploader)
NODEMCU-UPLOADER=../nodemcu-uploader/nodemcu-uploader.py
# Serial port
PORT=/dev/cu.usbserial-A602HRAZ
######################################################################
# End of user config
######################################################################
HTTP_FILES := $(wildcard http/*)
LUA_FILES := init.lua httpserver.lua httpserver-request.lua httpserver-static.lua httpserver-error.lua
# Print usage
usage:
@echo "make upload_http to upload files to be served"
@echo "make upload_server to upload the server code and init.lua"
@echo "make upload to upload all"
# Upload HTTP files only
upload_http: $(HTTP_FILES)
@$(NODEMCU-UPLOADER) -p $(PORT) upload $(foreach f, $^, -f $(f) -d $(f))
# Upload httpserver lua files (init and server module)
upload_server: $(LUA_FILES)
@$(NODEMCU-UPLOADER) -p $(PORT) upload $(foreach f, $^, -f $(f) -d $(f))
# Upload all
upload: $(LUA_FILES) $(HTTP_FILES)
@$(NODEMCU-UPLOADER) -p $(PORT) upload $(foreach f, $^, -f $(f) -d $(f))