value = 0
conn = net.createConnection(net.TCP, false)
conn:connect(80, "api.thingspeak.com")
conn:send("GET /update?key=REDACTED&field1="..value.." HTTP/1.1\r\nHOST: api.thingspeak.com\r\nConnection: close\r\nAccept: */*\r\n\r\n")
conn:close()
conn = nil
However, I'm trying to wrap this in a function, for easier re-use. Below code doesn't work
function send (value)
conn = net.createConnection(net.TCP, false)
conn:connect(80, "api.thingspeak.com")
conn:send("GET /update?key=REDACTED&field1="..value.." HTTP/1.1\r\nHOST: api.thingspeak.com\r\nConnection: close\r\nAccept: */*\r\n\r\n")
conn:close()
conn = nil
end
send(0)
And I don't get why. Any thoughts?