-->
Page 1 of 2

Can't set SSID in AP Mode

PostPosted: Tue Mar 03, 2015 1:35 pm
by Pram
Hey I got a serious problem, because I would like that the esp had a special SSID, but when I define that in the code and let the esp do it's magic it sets up a wifi with the SSID ESP_9BF5E5 and not the one I defined before. I need this working until thursday, because I am going to show that in front of an audience.

Here is my code:
init.lua
Code: Select all--include
require('ds18b20')

--wifi settings
--cfg={}
--cfg.ssid="nodeduino"
--cfg.pwd=""

--setup wifi ap
wifi.setmode(wifi.SOFTAP)
--wifi.ap.config(cfg)
wifi.ap.config({ssid="NODEDUINO",pwd=""})
print(wifi.ap.getip())

--in/outpus
led = 4
gpio.mode(led, gpio.OUTPUT)

tempp = 3
ds18b20.setup(tempp)

--variables
--ledstat = 0

--get temperature & store
t1=ds18b20.read()
t1=ds18b20.read()

--main
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.."<font size=\"12\">Nodeduino Beispiel</font>";
        buf = buf.."<p><font size=\"7\">Temperatur: "..t1.."&deg;C</font>&nbsp;</p>";
        buf = buf.."<p><a href=\"?pin=temp\"><button style=\"width:400px;height:200px\"><font size=\"7\">Aktualisieren</font></button></a>&nbsp;</p>";
        buf = buf.."<p><font size=\"7\">LED Status &auml;ndern:</font>&nbsp;</p>";
        buf = buf.."<p><a href=\"?pin=ON\"><button style=\"width:400px;height:200px\"><font size=\"7\">An</font></button></a>&nbsp;<a href=\"?pin=OFF\"><button style=\"width:400px;height:200px\"><font size=\"7\">Aus</font></button></a></p>";
        local _on,_off = "",""
       
        if(_GET.pin == "temp")then
          t1=ds18b20.read()
          t1=ds18b20.read()
        elseif(_GET.pin == "ON")then
          gpio.write(led, gpio.HIGH);
        elseif(_GET.pin == "OFF")then
          gpio.write(led, gpio.LOW);
        end
       
        client:send(buf);
        client:close();
        collectgarbage();
    end)
end)

Re: Can't set SSID in AP Mode

PostPosted: Wed Mar 04, 2015 11:43 am
by Pram
Got it working, cause you need at least a password of 8 characters, but is there no way of doing it without a password?

Re: Can't set SSID in AP Mode

PostPosted: Tue Mar 24, 2015 1:17 pm
by draco
Yes, there is.

This is how I did it:
Code: Select alllocal apSsidConfig = {}
apSsidConfig.ssid = apName
wifi.ap.config(apSsidConfig)


The only real difference between my (overly verbose) way and your one-liner is that I am NOT setting the pwd value at all, instead of setting it to "", an empty string.

i would expect this to work as well:
Code: Select allwifi.ap.config({ssid="MyNewSSID"})

but I'm not home right now to test it.

Re: Can't set SSID in AP Mode

PostPosted: Fri Jul 08, 2016 12:38 pm
by Zhymka
Hi,

I have similar problem, can't set channel on AP mode.
Code: Select alllocal APWifiConfig=
{
   ssid="SomeSSID",
   pwd="SomeMoreThanEightCharsPwd",
   channel=11
}

wifi.setmode(wifi.SOFTAP)
wifi.ap.config(APWifiConfig)

it remains on first...

if it is helpful i am using: NodeMCU 0.9.5 build 20150318 , Lua 5.1.4
update: ok, probably wrong firmware version