Last active
June 20, 2017 19:27
-
-
Save karrots/b5dc4151164945f4dc36f217ec904732 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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