Current Lua downloadable firmware will be posted here

User avatar
By Trickuncle
#40884 Ok, I should have just asked for more help - I've been going over the nodemcu docs and have not made a dent here yet. I guessed that I needed to invoke a callback and it needs to fire off a function when the callback happens so I made a 1ms delay called wait() and tried stuff like this:
Code: Select allconn:send('some string', wait())

but it does not seem to work.

Am I close? in left field? in the wrong zip code? What should the code look like that invokes the callback?
User avatar
By Trickuncle
#40995 @xtal:
if using nodemcu after 0.9.6 use the Call Back's
Send 1
CB send 2
CB send x
CB close


Can you show me a short fast example of just what the code should look like for your example? I get the general idea of using callbacks as an event to control program flow but that's all so far...
Thanks for any input!
User avatar
By xtal
#41004
Code: Select all
Web page code is in flash -- loaded by require

-------------------------------
local function LBuf(scnt,c)
   LBx = require("LB"..scnt)        -- load LB0,1,2,3,4
   local cbuf = LBx.B0()
   vt[scnt] = #cbuf     
     if #cbuf>=1455 then
       c:send(scnt.."---C Buffer > 1455 Error---\r\n")
     else
       c:send(cbuf)
     end 
   cbuf = nil
   package.loaded["LB"..scnt]=nil
   collectgarbage()
end       
============================================================================

--Rcv80 function snip


    rfh=vt.rfh
    cmx = vt.cmx
    if vt.pass1 == 1 then vt.pass1=0 else vt.pass1=1 end
    if vt.pass1 == 0 then vt.pass = vt.pass+1  end 
    collectgarbage()   
    Scnt=0
    Send80(c)               
end  ----------------- end of Rcv80 function
=============================================================================
function Send80(c)   
    if Scnt==0 then                     -- 1st CB
       LBuf(0,c)   --LBuf(Scnt,c) 

    elseif Scnt==1 then                 -- 2nd CB
       LBuf(1,c)   --LBuf(Scnt,c)     
                     
    elseif Scnt==2 then                 -- 3rd CB
       LBuf(2,c)   --LBuf(Scnt,c)
       
    elseif Scnt==3 then                 -- 4th CB

      while vt.pend == 1 do   -- wait if [D] working
      end     
      --LBuf(3,c)-- LBuf(Scnt,c)
         vt[4]=100
    local cbuf='<div><textarea name="cmds" cols="70" rows="18">'
          ..vt.sbuf..'</textarea></div><br>'         
          ..vt[0].." | "..vt[1].." | "..vt[2].." | "..vt[3].." | "..vt[4].." | "
          ..vt[0]+vt[1]+vt[2]+vt[3]+vt[4].."    Baud: "..vt.baud.." | "..vt.lua     
          vt[Scnt] = #cbuf     
          c:send(cbuf)
          cbuf = nil     
          collectgarbage()
 
    end   
    if Scnt >=4 then                   -- 5th - Last CB
       c:close()
       c=nil
       collectgarbage()
    end                         
         Scnt=Scnt+1                                       --- increment the counter
         vt.Lcb=vt[0]+vt[1]+vt[2]+vt[3]+vt[4]   --vt[4]           
         collectgarbage()   
end --function end