-->
Page 4 of 5

Re: Lua NodeMcu 0.9.4 build 20141222 -program does not work

PostPosted: Mon Jan 05, 2015 2:16 pm
by papagenic
ok, thanks,

but then how would you deal with an exemple which needs to keep a context between iterations?
Take this exemple:

Code: Select allwifi.sta.getap(function(apList)
  for sid,d in pairs(apList) do
   conn:send( '<option value="'..sid..'">'..sid..'</option>')
  end
end)


thanks

Re: Lua NodeMcu 0.9.4 build 20141222 -program does not work

PostPosted: Mon Jan 05, 2015 2:39 pm
by Markus Gritsch
With a generator. Read about coroutines, yield, and iterators here http://www.lua.org/pil/9.1.html and here http://www.lua.org/pil/9.3.html. Probably also about closure and lexical scoping here http://www.lua.org/pil/6.1.html.

If time permits read all of the online version of the first edition of "Programming in Lua" which covers Lua 5.0 or buy a newer edition.

BTW, 'isopen' from the example above is also a state which is stored between iterations. You can access the elements of your 'apList' in the same way.

Re: Lua NodeMcu 0.9.4 build 20141222 -program does not work

PostPosted: Wed Jan 07, 2015 8:56 am
by yes8s
Anyone get anywhere with this issue?

I too started getting the blank web page when I went to >=0.9.4. Previously, it was sending large chunks of html data ~1200-1400 bytes at a time with no issue.

Now it does seem that if there are several conn:sent(xx) commands in a row within a conn:on('sent'..) function (as you'd get when reading then sending lines from a html file) they are lost due to the conn:on('sent'..) being called prematurely over and over again.

My current workaround is to read and send each html line of text line by line which is soooo slow now. Even smallish webpages can be seen to load bit by bit on the browser. It's ugly.

Zeroday has said nothing has changed in the lua API but there was some change in the SDK which could affect things but I don't think he's checked it.

Re: Lua NodeMcu 0.9.4 build 20141222 -program does not work

PostPosted: Thu Jan 08, 2015 2:10 am
by Markus Gritsch
For reference: The explanation is given here:
viewtopic.php?f=18&t=1160