LeeT WiFiLamp code and test
Dependencies: ESP8266_WebServer mbed
Fork of WiFiLamp by
Diff: main.cpp
- Revision:
- 12:fbf950985e1c
- Parent:
- 10:f48a9f923271
- Parent:
- 11:3ab606a42227
- Child:
- 13:1e8f27da036a
- Child:
- 16:f2f2da9ef9ab
--- a/main.cpp Sun Dec 28 15:28:27 2014 +0000 +++ b/main.cpp Sun Dec 28 16:09:20 2014 +0000 @@ -75,23 +75,23 @@ if( request->URI == "/" ) { httpReply = "<html><title>WiFi Lamp</title><body><h1>The WiFi Lamp V0.01 is alive ...</h1><br>Quick colour links:<br><a href='/red'>Red</a><br><a href='/green'>Green</a><br><a href='/blue'>Blue</a><br><a href='/white'>White</a><br></body></html>"; setColor(0,0,0); - server.SendHTMLReply(request->LinkID, httpReply); + server.SendReply(request->LinkID, httpReply, mimeHTML); } else if( request->URI == "/red" ) { httpReply = "<html><head><title>WiFi Lamp</title></head><body><h1>The WiFi Lamp is now Red - To Turn <a href='/'>Off</a></h1></body></html>"; setColor(100, 0, 0); - server.SendHTMLReply(request->LinkID, httpReply); + server.SendReply(request->LinkID, httpReply, mimeHTML); } else if( request->URI == "/green" ) { httpReply = "<html><head><title>WiFi Lamp</title></head><body><h1>The WiFi Lamp is now Green - To Turn <a href='/'>Off</a></h1></body></html>"; setColor(0, 100, 0); - server.SendHTMLReply(request->LinkID, httpReply); + server.SendReply(request->LinkID, httpReply, mimeHTML); } else if( request->URI == "/blue" ) { httpReply = "<html><head><title>WiFi Lamp</title></head><body><h1>The WiFi Lamp is now Blue - To Turn <a href='/'>Off</a></h1></body></html>"; setColor(0, 0, 100); - server.SendHTMLReply(request->LinkID, httpReply); + server.SendReply(request->LinkID, httpReply, mimeHTML); } else if( request->URI == "/white" ) { httpReply = "<html><head><title>WiFi Lamp</title></head><body><h1>The WiFi Lamp is now White - To Turn <a href='/'>Off</a></h1></body></html>"; setColor(100, 100, 100); - server.SendHTMLReply(request->LinkID, httpReply); + server.SendReply(request->LinkID, httpReply, mimeHTML); } else if( request->URI == "/setcolor" ) { int r=0, g=0, b=0; @@ -104,9 +104,9 @@ setColor( r,g,b ); httpReply = "<html><head><title>WiFi Lamp</title></head><body>ok</body></html>"; - server.SendHTMLReply(request->LinkID, httpReply); + server.SendReply(request->LinkID, httpReply, mimeHTML); } else { - server.Send404Reply(request->LinkID); + server.Send404Error(request->LinkID); } pc.printf("\r\nHTTP Reply Sent\r\n"); delete request;