Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of HTTPServer by
HTTPServer.cpp
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 #include "EthernetNetIf.h" 00004 #include "HTTPServer.h" 00005 #include "RPCFunction.h" //ADD Here!! 00006 DigitalOut led1(LED1,"led1"); 00007 DigitalOut led2(LED2,"led2"); 00008 DigitalOut led3(LED3,"led3"); 00009 DigitalOut led4(LED4,"led4"); 00010 00011 TextLCD lcd(p24, p26, p27, p28, p29, p30); 00012 00013 #if 1 00014 /* 00015 * Use DHCP 00016 */ 00017 EthernetNetIf ethif; 00018 #else 00019 /* 00020 * Use "static IP address" (Parameters:IP, Subnet mask, Gateway, DNS) 00021 */ 00022 EthernetNetIf ethif(IpAddr(xxx,xxx,xxx,xxx), IpAddr(xxx,xxx,xxx,xxx), IpAddr(xxx,xxx,xxx,xxx), IpAddr(xxx,xxx,xxx,xxx)); 00023 #endif 00024 00025 HTTPServer server; 00026 LocalFileSystem local("local"); 00027 void LcdWrite(char *input,char *output); //ADD Here!! 00028 RPCFunction rpcFunc(&LcdWrite, "LcdWrite"); //ADD Here!! 00029 00030 int main(void) { 00031 00032 Base::add_rpc_class<DigitalOut>(); 00033 00034 lcd.cls(); 00035 lcd.locate(0,0); 00036 lcd.printf("Program init.. "); 00037 00038 if (ethif.setup()) { 00039 error("Ethernet setup failed."); 00040 return 1; 00041 } 00042 IpAddr ethIp=ethif.getIp(); 00043 00044 lcd.locate(0,1); 00045 lcd.printf("%d.%d.%d.%d", ethIp[0], ethIp[1], ethIp[2], ethIp[3]); 00046 led1=1; 00047 wait(1); 00048 server.addHandler<SimpleHandler>("/hello"); 00049 server.addHandler<RPCHandler>("/rpc"); 00050 FSHandler::mount("/local", "/"); 00051 server.addHandler<FSHandler>("/"); 00052 server.bind(80); 00053 while (1) { 00054 Net::poll(); 00055 } 00056 return 0; 00057 } 00058 void LcdWrite(char *input , char *output) //ADD Here!! 00059 { 00060 lcd.locate(0,1); 00061 lcd.printf("%s",input); 00062 }
Generated on Wed Jul 13 2022 01:58:46 by
1.7.2
