toshio masuda
/
HTTP_S_text
rev0.1
ページ作成練習用
Revision 1:89479d6c8b09, committed 2013-04-18
- Comitter:
- MasudaToshio
- Date:
- Thu Apr 18 12:02:23 2013 +0000
- Parent:
- 0:af120baf5a2e
- Commit message:
- BoardOrange; HTTP_server_DHCP
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r af120baf5a2e -r 89479d6c8b09 main.cpp --- a/main.cpp Thu Apr 18 10:01:49 2013 +0000 +++ b/main.cpp Thu Apr 18 12:02:23 2013 +0000 @@ -3,75 +3,56 @@ #include "EthernetNetIf.h" #include "HTTPServer.h" #include "RPCFunction.h" //ADD Here!! + DigitalOut led1(LED1,"led1"); DigitalOut led2(LED2,"led2"); DigitalOut led3(LED3,"led3"); DigitalOut led4(LED4,"led4"); - TextLCD lcd(p24, p26, p27, p28, p29, p30); - -#if 1 -/* - * Use DHCP - */ - EthernetNetIf ethif; -#else -/* - * Use "static IP address" (Parameters:IP, Subnet mask, Gateway, DNS) - */ - EthernetNetIf ethif(IpAddr(xxx,xxx,xxx,xxx), IpAddr(xxx,xxx,xxx,xxx), IpAddr(xxx,xxx,xxx,xxx), IpAddr(xxx,xxx,xxx,xxx)); -#endif - + + EthernetNetIf ethif; HTTPServer server; LocalFileSystem local("local"); void LcdWrite(char *input,char *output); //ADD Here!! RPCFunction rpcFunc(&LcdWrite, "LcdWrite"); //ADD Here!! - + +///////////////////////////////////////////////////// +// main +///////////////////////////////////////////////////// int main(void) { - Base::add_rpc_class<DigitalOut>(); - lcd.cls(); lcd.locate(0,0); lcd.printf("Program init.. "); - + if (ethif.setup()) { error("Ethernet setup failed."); return 1; } + IpAddr ethIp=ethif.getIp(); - lcd.locate(0,1); lcd.printf("%d.%d.%d.%d", ethIp[0], ethIp[1], ethIp[2], ethIp[3]); led1=1; wait(1); + server.addHandler<SimpleHandler>("/hello"); server.addHandler<RPCHandler>("/rpc"); FSHandler::mount("/local", "/"); server.addHandler<FSHandler>("/"); server.bind(80); + while (1) { Net::poll(); } return 0; } - - - - -void LcdWrite(char *input , char *output) //ADD Here!! -{ - - if( input[0] == 0x31 ){ - led1 = ! led1 ; - }else{ - - lcd.locate(0,0); - lcd.printf( " " ); - lcd.printf("%s",input); - lcd.printf( " " ); - - } +///////////////////////////////////////////////////// +// LCD +///////////////////////////////////////////////////// +void LcdWrite(char *input , char *output) { + lcd.cls(); + lcd.locate(0,0); + lcd.printf("%s",input); } -