Modified to run on Renesas GR Peach board
Fork of HTTP-Server by
Revision 11:d03f12a19999, committed 2015-10-07
- Comitter:
- webOnBoard
- Date:
- Wed Oct 07 20:35:31 2015 +0000
- Parent:
- 10:8b4c3d605bf0
- Commit message:
- Modified for GRPeach
Changed in this revision
--- a/EthernetInterface.lib Thu Jul 18 10:10:14 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/feb11/code/EthernetInterface/#f533841d34cb
--- a/Formatter.cpp Thu Jul 18 10:10:14 2013 +0000 +++ b/Formatter.cpp Wed Oct 07 20:35:31 2015 +0000 @@ -2,6 +2,7 @@ #include "mbed.h" #include "RPCObjectManager.h" #include "EthernetInterface.h" +#include "page3.h" const char *SIMPLE_HTML_CODE = "\ <!DOCTYPE html>\ @@ -78,7 +79,7 @@ </body> \ </html>"; -static char chunk[1024]; +static char chunk[2048]; Formatter::Formatter(int nb): currentChunk(0), @@ -97,7 +98,8 @@ } else currentChunk = 0; - + //strcat(chunk, Page3); + return chunk; } @@ -113,8 +115,9 @@ void SimpleHTMLFormatter::get_chunk(const int c, char* reply) { - strcat(chunk, SIMPLE_HTML_CODE); - + printf("using simple formatter\n\r"); + strcat(chunk, Page3); + /* if(reply != NULL && strlen(reply) != 0) { strcat(chunk, "RPC reply : "); @@ -135,7 +138,7 @@ strcat(chunk, "</ul>"); } - strcat(chunk, "</body></html>"); + strcat(chunk, "</body></html>");*/ } InteractiveHTMLFormatter::InteractiveHTMLFormatter(): @@ -145,9 +148,12 @@ void InteractiveHTMLFormatter::get_chunk(const int c, char *reply) { + printf("\n\r c for loop is %d\n\r",c); if(c == 0) sprintf(chunk, INTERACTIVE_HTML_CODE_1, EthernetInterface::getIPAddress()); + //sprintf(chunk, Page3, sizeof(Page3));//, EthernetInterface::getIPAddress()); + else if(c == 1) { if(reply != NULL && strlen(reply) != 0) @@ -179,6 +185,7 @@ } else if(c == 2) strcat(chunk, INTERACTIVE_HTML_CODE_2); + printf("done with formatter\n\r"); }
--- a/HTTPServer.cpp Thu Jul 18 10:10:14 2013 +0000 +++ b/HTTPServer.cpp Wed Oct 07 20:35:31 2015 +0000 @@ -63,7 +63,7 @@ } else if(n != -1) { - printf("Received data\n"); + printf("Received data\n\r"); buffer[n] = '\0'; handle_request(buffer); if(formatter != NULL) @@ -75,7 +75,7 @@ c.send(page, strlen(page)+1); page = formatter->get_page(reply); }while(strlen(page)>0); - printf("done\n"); + printf("done\n\r"); } else c.send(INVALID_FORMATTER, strlen(INVALID_FORMATTER)+1);
--- a/RequestHandler.cpp Thu Jul 18 10:10:14 2013 +0000 +++ b/RequestHandler.cpp Wed Oct 07 20:35:31 2015 +0000 @@ -10,6 +10,7 @@ void GetRequestHandler::handle(const RPCCommand& cmd, char *reply) { + printf("in getrequesthandler\n\r"); switch(cmd.get_type()) { case DELETE:
--- a/main.cpp Thu Jul 18 10:10:14 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -#include "mbed.h" -#include "EthernetInterface.h" -#include "mbed_rpc.h" -#include "RPCCommand.h" -#include "HTTPServer.h" -#include "Formatter.h" -#include "RequestHandler.h" -#include "RPCType.h" - -#define SERVER_PORT 80 - -HTTPServer create_simple_server() -{ - HTTPServer srv; - srv.add_request_handler("DELETE", new DeleteRequestHandler()); - srv.add_request_handler("GET", new GetRequestHandler()); - srv.add_request_handler("PUT", new PutRequestHandler()); - return srv; -} - -HTTPServer create_interactive_server() -{ - HTTPServer srv(new InteractiveHTMLFormatter()); - srv.add_request_handler("GET", new ComplexRequestHandler()); - return srv; -} - -int main(void) -{ - RPCType::instance().register_types(); - - EthernetInterface eth; - if(eth.init()) - { - printf("Error while initializing the ethernet interface.\n"); - return -1; - } - if(eth.connect()) - { - printf("Error while starting the ethernet interface.\n"); - return -1; - } - - printf("IP Address is %s\n", eth.getIPAddress()); - - HTTPServer srv = create_interactive_server(); - - if(!srv.init(SERVER_PORT)) - { - eth.disconnect(); - return -1; - } - - srv.run(); - - return 0; -} -
--- a/mbed-rpc.lib Thu Jul 18 10:10:14 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed-rpc/#1ecadde1c929
--- a/mbed-rtos.lib Thu Jul 18 10:10:14 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#58b30ac3f00e
--- a/mbed.bld Thu Jul 18 10:10:14 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17 \ No newline at end of file