Current Lua downloadable firmware will be posted here

User avatar
By renelima
#56711 I have this code
Code: Select allsrv:on("receive", function(s, data)
    print("received: " .. data)
    if(data == "teste")then
        print("fkdjsfsjdkfdsdfks")
    end
    s:send("echo: " .. data)
end)


I need to make a "IF" in the message that comes to activate a GPIO, how can I do this? Thus this not working.
User avatar
By marcelstoer
#56758
renelima wrote:Thus this not working.


Why is it not working? The sketch looks very similar to what I posted at http://stackoverflow.com/a/36769999/131929 and was confirmed to work just fine. 'print("received: " .. data)' prints the value of the 'data' parameter so it should be easy to verify what value it has.

As per http://nodemcu.readthedocs.io/en/dev/en ... etsocketon the type of 'data' is string and in Lua '==' for strings will return true if contents of the strings are equal.