I have a project going on using two NodeMCUs and LUA. One NodeMCU (server) is hosting a simple web server that reacts to specific URL parameters. For example, I go to: http://192.168.1.179/?pin=ON1 in my browser and it's LEDs light up etc. I want to recreate doing this with the other NodeMCU (client) at the push of a button. The only part that is holding me up is this HTTP GET request.
For starters, I'd like to simply use the http module .. but the module isn't present in the latest firmware build available. I don't know why this is? I'm not up to build the latest - latest. 2 version difference there... I have submitted for a custom build.
require('http')
stdin:1: module 'http' not found:
no field package.preload['http']
no file 'http.lc'
no file 'http.lua'
Apparently there are other, older, means of doing so:
conn=net.createConnection(net.TCP, false)
conn:on("receive", function(conn, pl) print(pl) end)
conn:connect(80,"192.168.1.179")
conn:send("GET /?pin=ON1 HTTP/1.1\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n")
I've been playing around trying to get it to work. The DNS fails with the full path. As is, it just outputs 0 for the print portion. Mind you, this is a local server and it's address is directly specified. I'm getting a DHCP from the router and I've tried a static IP. I'm at a loss and don't know what else to do. It's the last step in completing this project as well so it is driving me nuts! Any help would be appreciated. I should note I lost my script for the server so I cannot reference it. It works though. x_X'