As the title says... Chat on...

User avatar
By faramon
#65538 I try to set AP:
Code: Select allwifi.setmode(wifi.SOFTAP)
wifi.ap.config({ssid="ESP8266"}) 
wifi.ap.setip({ip="192.168.0.1",netmask="255.255.255.0",gateway="192.168.0.1"})
print("Setting up webserver")
print("IP Address:",wifi.ap.getip())
and I get IP 192.168.0.1 in print("IP Address:",wifi.ap.getip()).
My AP works and I'am able to see it in my wifi networks on smartphone or my laptop.
I can even connect to AP. But when I try to see settings in my laptop or smartphone for my AP that is connected, there is 192.168.0.2 why 192.168.0.2 ?
If I do not set wifi.ap.setip then I get 192.168.4.1 as standard IP. But same in properties 192.168.4.2 ?
How to retain 192.168.0.1 or 192.168.4.1 because in this code I dont see Hello, NodeMcu:
Code: Select allsrv = nil
   srv=net.createServer(net.TCP)
   srv:listen(80,function(conn)
    conn:on("receive",function(conn,payload)
            local buf = ""
            print("Payload: " .. payload)
            buf = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"
            buf = buf .. "<!DOCTYPE HTML>\r\n"
            buf = buf .. "<html><body>"
            buf = buf .. "<h1> Hello, NodeMcu.</h1><br>"
            buf = buf .. "</body></html>"
            conn:send(buf)
            collectgarbage()
        end)
        conn:on("sent",function(conn)
            conn:close()
            collectgarbage()
        end)
    ...
Thanx,
Faramon
Last edited by faramon on Tue May 09, 2017 1:34 am, edited 1 time in total.