ソースの整理中ですが、利用はできます。

Dependencies:   EthernetInterface HttpServer TextLCD mbed-rpc mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 //#define DNS_SERVER_ADDRESS(ipaddr)        (ip4_addr_set_u32(ipaddr, ipaddr_addr("208.67.222.222"))) /* resolver1.opendns.com */
00002 #include "mbed.h"
00003 #include "rtos.h"
00004 #include "EthernetInterface.h"
00005 #include "HTTPServer.h"
00006 #include "mbed_rpc.h"
00007 #include "TextLCD.h"
00008 
00009 EthernetInterface eth;
00010 LocalFileSystem local("local");
00011 DigitalOut led4(LED4);
00012 //DigitalOut led1(LED1);
00013 TextLCD lcd(p24, p26, p27, p28, p29, p30);
00014 
00015 void LcdWrite(Arguments* arg, Reply* r);void LcdWrite(Arguments* arg, Reply* r);
00016 void aliveState(void const *args)
00017 {
00018     while (true) {
00019         led4 = !led4;
00020         Thread::wait(1000);
00021     }
00022 }
00023 int main()
00024 {
00025     printf("********* PROGRAM START ***********\r\n");
00026     Thread thread(aliveState);
00027     lcd.cls();
00028     lcd.locate(0,0);
00029     
00030     printf("********* RPC Initialize ***********\r\n");
00031     RPC::add_rpc_class<RpcDigitalOut>();
00032     RPC::construct<RpcDigitalOut, PinName, const char*>(LED1, "led1");
00033     RPC::construct<RpcDigitalOut, PinName, const char*>(LED2, "led2");
00034     RPC::construct<RpcDigitalOut, PinName, const char*>(LED3, "led3");
00035     RPCFunction rpcFunc(LcdWrite, "LcdWrite"); 
00036     
00037     printf("EthernetInterface Setting up...\r\n");
00038     if(eth.init()!=0) {                             //for DHCP Server
00039        // if(eth.init("133.11.168.23","255.255.255.0","133.11.168.1")!=0) { //for Static IP Address
00040         printf("EthernetInterface Initialize Error \r\n");
00041         return -1;
00042     }
00043     if(eth.connect()!=0) {
00044         printf("EthernetInterface Connect Error \r\n");
00045         return -1;
00046     }
00047     printf("IP Address is %s\r\n", eth.getIPAddress());
00048     printf("NetMask is %s\r\n", eth.getNetworkMask());
00049     printf("Gateway Address is %s\r\n", eth.getGateway());
00050     printf("Ethernet Setup OK\r\n");
00051 
00052     FSHandler::mount("/local","/");
00053     
00054     lcd.locate(0,0);
00055     lcd.printf("%s",eth.getIPAddress());
00056     HTTPServerStart(80);
00057 }
00058 
00059 void LcdWrite(Arguments* arg, Reply* r)  //RPC Call
00060 {
00061     lcd.locate(0,1);
00062     lcd.printf("%s",arg->argv[0]);
00063 }
00064