Created
September 23, 2013 22:07
-
-
Save holmesal/6677637 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
var tessel = require('tessel'); | |
var net = tessel.net; | |
console.log("connecting"); | |
var client; | |
var port; | |
var clients = []; | |
setInterval(function () { | |
console.log("REMOVER"); | |
if (clients.length >1) { | |
console.log("Should Remove"); | |
} | |
}, 4000); | |
checkStatus = function() { | |
console.log("Checking Status"); | |
port = tessel.port('c'); | |
client = net.connect(80, "50.97.161.229", function() { | |
client.write("GET /github.com HTTP/1.0\r\nAccept: *\/*\r\nHost: downforeveryoneorjustme.com\r\n\r\n"); | |
}); | |
var down = false; | |
client.on("data", function(data){ | |
if (data.indexOf("down from here") > -1 ) { | |
console.log("Still Down"); | |
down = true; | |
} | |
if (data.indexOf("</html>") > -1) { | |
console.log("closed"); | |
if (down === true) { | |
console.log("TURNING ON"); | |
// tessel.led(2).low(); | |
port.gpio(1).output().high(); | |
port.gpio(2).output().high(); | |
port.gpio(3).output().low(); | |
} else { | |
console.log("TURNING OFF"); | |
port.gpio(1).output().low(); | |
port.gpio(2).output().low(); | |
port.gpio(3).output().high(); | |
} | |
console.log("HERE"); | |
clients.push(client); | |
} | |
}); | |
}; | |
setInterval(checkStatus, 3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment