Left here for archival purposes.

User avatar
By phlux
#3181 Connecting to wireless networks that use long WPA keys does not work.

The maximum length for WPA keys is 63 characters. There seems to be a check for this in NodeMcu, but it already fails if the key length is >32 and produces the following error:

Code: Select all> wifi.sta.config("SSID","012345678901234567890123456789012")
lua: stdin:1: pwd:<64
>


A key length of 32 is the longest that is accepted without the error. So at the moment connecting to networks that use long keys is not possible.
This is probably not too hard to fix.
User avatar
By zeroday
#3202
phlux wrote:Connecting to wireless networks that use long WPA keys does not work.

The maximum length for WPA keys is 63 characters. There seems to be a check for this in NodeMcu, but it already fails if the key length is >32 and produces the following error:

Code: Select all> wifi.sta.config("SSID","012345678901234567890123456789012")
lua: stdin:1: pwd:<64
>


A key length of 32 is the longest that is accepted without the error. So at the moment connecting to networks that use long keys is not possible.
This is probably not too hard to fix.


fixed in build version 20141124.
Thank you.
User avatar
By zeroday
#3203
ThomasW wrote:Hi,

socket:on("connection",..) seems not to be called in server mode, running the example below I get "Received" and "Disconnected" just fine but "Connected" never shows up

Thomas

Code: Select allsrv=net.createServer(net.TCP)
srv:listen(80,function(conn)
   conn:on("connection",function(conn)
      print("Connected")
   end)
   conn:on("receive",function(conn,payload)
      print("Received:" .. payload)
   end)
   conn:on("disconnection",function(conn)
      print("Disconnected")
   end)
end)


Yes, "connection" event callback for a net.socket only apply to socket created by createConnection.
when in server mode. the conn from listen() actually is connected already.
Code: Select allsrv:listen(80,function(conn)  end)

means:
Code: Select allsrv:on("connection",function(conn)  end)   --only MEANS this but can't execute.
srv:listen(80)

But I put this event in listen().
User avatar
By scargill
#3226 Signed in - and I have an IP address. I thought I'd give the TCP listener a shot.

I set this up..

l1="0\n"

sv=net.createServer(net.TCP, 90) -- 30s time out for a inactive client
sv:listen(4000,function(c)
c:on("receive", function(sck, pl)
print(pl)
if (pl=="GO1\n") then c:send(l1)
elseif pl=="YES1\n" then l1="1\n" c:send("OK\n")
elseif pl=="NO1\n" then l1="0\n" c:send("OK\n")
else c:send("0\n")
end
end)
end)

This worked very well - and quickly - I could use my Android App to simulate turning a light on and off - and the status request "GO1\n showed me the state of the string (which in reality would be a LED or whatever.

Of course that's too small to be of real use.. so I tried to make it bigger - after resetting the board..

Here is the sequence from power up...This time for 4 virtual outputs..

NodeMcu 0.9.2 build 20141124 powered by Lua 5.1.4
>
Loading functions
Connecting
Connected to.loft-east.IP:.192.168.0.22
OK

> l1="0\n"
> l2="0\n"
> l3="0\n"
> l4="0\n"
> sv=net.createServer(net.TCP, 90) -- 30s time out for a inactive client
> sv:listen(4000,function(c)
>>
>> c:on("receive", function(sck, pl)
>> print(pl)
>> if (pl=="GO1\n") then c:send(l1)
>> elseif pl=="GO2\n" then c:send(l2)
>> elseif pl=="GO3\n" then c:send(l3)
>> elseif pl=="GO4\n" then c:send(l4)
>> elseif pl=="YES1\n" then l1="1\n" c:send("OK\n")
>> elseif pl=="NO1\n" then l1="0\n" c:send("OK\n")
>> elseif pl=="YES2\n" then l2="1\n" c:send("OK\n")
>> elseif pl=="NO2\n" then l2="0\n" c:send("OK\n")
>> elseif pl=="YES3\n" then l3="1\n" c:send("OK\n")
>> elseif pl=="NO3\n" then l3="0\n" c:send("OK\n")
>> elseif pl=="YES4\n" then l4="1\n" c:send("OK\n")
c_GORSvf.SzfJSzfn
Pete's LUA module 0.1
NodeMcu 0.9.2 build 20141124 powered by Lua 5.1.4
>
Loading functions
Connecting
Connected to.loft-east.IP:.192.168.0.22
OK


This is a trivial example - yet as you can see, the interpreter is giving up before the final command - and once again rebooting.

. Here's what I TRIED to put in.

l1="0\n"
l2="0\n"
l3="0\n"
l4="0\n"
sv=net.createServer(net.TCP, 90) -- 30s time out for a inactive client
sv:listen(4000,function(c)
c:on("receive", function(sck, pl)
print(pl)
if (pl=="GO1\n") then c:send(l1)
elseif pl=="GO2\n" then c:send(l2)
elseif pl=="GO3\n" then c:send(l3)
elseif pl=="GO4\n" then c:send(l4)
elseif pl=="YES1\n" then l1="1\n" c:send("OK\n")
elseif pl=="NO1\n" then l1="0\n" c:send("OK\n")
elseif pl=="YES2\n" then l2="1\n" c:send("OK\n")
elseif pl=="NO2\n" then l2="0\n" c:send("OK\n")
elseif pl=="YES3\n" then l3="1\n" c:send("OK\n")
elseif pl=="NO3\n" then l3="0\n" c:send("OK\n")
elseif pl=="YES4\n" then l4="1\n" c:send("OK\n")
elseif pl=="NO4\n" then l4="0\n" c:send("OK\n")
else c:send("0\n")
end
end)
end)