I have a program that receive string in a variable named request. The data in this variable will be used in a file named nodo.lua, all is like this.
The string are received in this function:
srv=net.createServer(net.TCP, 4)
print("Server created on " .. wifi.sta.getip())
srv:listen(80,function(conn)
conn:on("receive",function(conn, request)
print(request)
The file are called here.
file.open("nodo.lua")
dofile("nodo.lua", "r+")
file.close()
and, node.lua are this:
print(request)
print(dato_ip)
print(dato_mask)
print(dato_gat)
if (string.find(request,"Guardar")~= nil) then
gpio.write(0, gpio.LOW)
print("Encendido", data)
if (string.find(request,"IP")~= nil) then
dato_ip = string.match(request, 'IP=.-&')
dato_mask = string.match(request, 'MASCARA=.-&')
dato_gat = string.match(request, 'GATEWAY=.-&')
print(dato_ip)
print(dato_mask)
print(dato_gat)
file.open("Archivo.txt", "w")
file.write(dato_ip)
file.write(dato_mask)
file.write(dato_gat)
file.close()
end
end
The problem is... If i place all content of node.lua in the main program, the data in request exist and i can get from the request the string of IP, Mask and Gateway. But if i use the code inside the node.lua, request are ever nil.
How can i get that the data in request can be used inside the file node.lua?
Thank you.