I have following code successfully running on my ESP8266, nodemcu-1.5.4.1 firmware and I can open my web service on Android ( Chrome, Firefox), and Windows (IE, Chrome) but it will never open on IOS device (Safari,Chrome)
Where should I insert the commends to get IOS browser *Safari, Chrome) to display a webpage ?
client:send("HTTP/1.1 200 OK\r\n");
client:send("Content-type: text/html\r\n");
client:send("Connection: close\r\n\r\n");
Following code runs well allowing to trigger relay connection:
-- must switch to 9600 baud to control relay
uart.setup(0,9600,8,0,1)
-- join wifi
wifi.setmode(wifi.SOFTAP)
local cfg
cfg = {
ip = "10.10.10.10",
netmask = "255.255.255.0",
gateway = "10.10.10.10"
}
wifi.ap.setip(cfg)
cfg = {
ssid = "XXXX",
pwd = "xxxx"
}
wifi.ap.config(cfg)
-- Lua web server
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive", function(client,request)
local buf = "";
local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");
if(method == nil)then
_, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");
end
local _GET = {}
if (vars ~= nil)then
for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
_GET[k] = v
end
end
buf = buf.."<head><meta name='viewport' content='width=200px, initial-scale=1.0'/>"
buf = buf.."<style>body { background-color: #606060;} h2{border: 4px solid #000; border-radius: 23px; padding: 20px; font-size: 80px;} h1{color: #fff; margin-top: 15px;} footer{color: #0000ee; font-size: 15px; margin-top: 25px;}</style>"
buf = buf.."<font face='verdana'><center><h1> WiFi Inteligent House</h1></center>";
buf = buf.."<a href=\"?pin=ON1\"> <center><h2>_1_</h2></center></a> <a";
buf = buf.."<footer><center><p>Project 2017</p></center></footer>";
local _on,_off = "",""
if(_GET.pin == "ON1")then
tmr.stop(0);
uart.write( 0, 0xA0,0x01,0x01,0xA2);
tmr.alarm(0, 1000, 1, function() uart.write( 0, 0xA0,0x01,0x00,0xA1) end )
end
client:send(buf);
client:close();
collectgarbage();
end)
end)