Skip to content

Instantly share code, notes, and snippets.

@karrots
Last active June 20, 2017 19:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karrots/b5dc4151164945f4dc36f217ec904732 to your computer and use it in GitHub Desktop.
Save karrots/b5dc4151164945f4dc36f217ec904732 to your computer and use it in GitHub Desktop.
local function testHTTP()
net.dns.resolve("www.google.com", function(sk, ip)
if ip == nil then
print("DNS fail!")
else
print("Resolved: " .. ip)
end
end)
http.get("http://httpbin.org/ip", nil, function(code, data, result)
if code < 0 then
print("HTTP request failed")
-- print("IP: " .. myWifi.getIp())
print("code: " .. code)
else
print(code, data)
end
end)
end
wifi.sta.eventMonReg(wifi.STA_GOTIP, function() testHTTP() end)
wifi.setmode(wifi.STATION)
wifi.sta.config(myConfig.WIFI_SSID, myConfig.WIFI_PASSWORD)
net.dns.setdnsserver("8.8.8.8", 0)
net.dns.setdnsserver("192.168.178.1", 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment