* Web_Demo.pde -- sample code for Webduino server library */ /* * To use this demo, enter one of the following USLs into your browser. * Replace "host" with the IP address assigned to the Arduino. * * http://host/ * http://host/acOn * * This URL turns on the Air Conditioner * */ #include "SPI.h" #include "Ethernet.h" #include "WebServer.h" #include // no-cost stream operator as described at // http://sundial.org/arduino/?page_id=119 template inline Print &operator <<(Print &obj, T arg) { obj.print(arg); return obj; } //IR Variable declaration IRsend irsend; // CHANGE THIS TO YOUR OWN UNIQUE VALUE static uint8_t mac[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // CHANGE THIS TO MATCH YOUR HOST NETWORK static uint8_t ip[] = { 192, 168, 1, X }; #define PREFIX "" WebServer webserver(PREFIX, 80 ); //ASSIGN PORT HERE // commands are functions that get called by the webserver framework // they send the IR Code to the AC void acOn(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete) { if (type == WebServer::POST) { server.httpFail(); return; } //server.httpSuccess(false, "application/acOn"); server.httpSuccess(); //Replace for your IR Code here. irsend.sendNEC(0x80FF48B7, 32); //irsend.send(IRTYPE)(0x(IRCODE), (BITS)); delay(40); } void tempUp(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete) { if (type == WebServer::POST) { server.httpFail(); return; } server.httpSuccess(); //Replace for your IR Code here. irsend.sendNEC(0x80FFC8A7, 32); //irsend.send(COMPANYIR)(0x(IRCODE), (BITS)); delay(40); } void tempDown(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete) { if (type == WebServer::POST) { server.httpFail(); return; } server.httpSuccess(); //Replace for your IR Code here. irsend.sendNEC(0x80FF5837, 32); // delay(40); } void timer(WebServer &server, WebServer::ConnectionType type, char *url_tail, bool tail_complete) { if (type == WebServer::POST) { server.httpFail(); return; } server.httpSuccess(); //Replace for your IR Code here. irsend.sendNEC(0x80FFD827, 32); // delay(40); } void setup() { Ethernet.begin(mac, ip); webserver.begin(); //Rename the commands to your liking webserver.addCommand("acon", &acOn); webserver.addCommand("tempup", &tempUp); webserver.addCommand("tempdown", &tempDown); webserver.addCommand("timer", &timer); } void loop() { // process incoming connections one at a time forever webserver.processConnection(); // if you wanted to do other work based on a connecton, it would go here }