toshio masuda
/
HTTP_S_text
rev0.1
ページ作成練習用
main.cpp@1:89479d6c8b09, 2013-04-18 (annotated)
- Committer:
- MasudaToshio
- Date:
- Thu Apr 18 12:02:23 2013 +0000
- Revision:
- 1:89479d6c8b09
- Parent:
- 0:af120baf5a2e
BoardOrange; HTTP_server_DHCP
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MasudaToshio | 0:af120baf5a2e | 1 | #include "mbed.h" |
MasudaToshio | 0:af120baf5a2e | 2 | #include "TextLCD.h" |
MasudaToshio | 0:af120baf5a2e | 3 | #include "EthernetNetIf.h" |
MasudaToshio | 0:af120baf5a2e | 4 | #include "HTTPServer.h" |
MasudaToshio | 0:af120baf5a2e | 5 | #include "RPCFunction.h" //ADD Here!! |
MasudaToshio | 1:89479d6c8b09 | 6 | |
MasudaToshio | 0:af120baf5a2e | 7 | DigitalOut led1(LED1,"led1"); |
MasudaToshio | 0:af120baf5a2e | 8 | DigitalOut led2(LED2,"led2"); |
MasudaToshio | 0:af120baf5a2e | 9 | DigitalOut led3(LED3,"led3"); |
MasudaToshio | 0:af120baf5a2e | 10 | DigitalOut led4(LED4,"led4"); |
MasudaToshio | 0:af120baf5a2e | 11 | TextLCD lcd(p24, p26, p27, p28, p29, p30); |
MasudaToshio | 1:89479d6c8b09 | 12 | |
MasudaToshio | 1:89479d6c8b09 | 13 | EthernetNetIf ethif; |
MasudaToshio | 0:af120baf5a2e | 14 | HTTPServer server; |
MasudaToshio | 0:af120baf5a2e | 15 | LocalFileSystem local("local"); |
MasudaToshio | 0:af120baf5a2e | 16 | void LcdWrite(char *input,char *output); //ADD Here!! |
MasudaToshio | 0:af120baf5a2e | 17 | RPCFunction rpcFunc(&LcdWrite, "LcdWrite"); //ADD Here!! |
MasudaToshio | 1:89479d6c8b09 | 18 | |
MasudaToshio | 1:89479d6c8b09 | 19 | ///////////////////////////////////////////////////// |
MasudaToshio | 1:89479d6c8b09 | 20 | // main |
MasudaToshio | 1:89479d6c8b09 | 21 | ///////////////////////////////////////////////////// |
MasudaToshio | 0:af120baf5a2e | 22 | int main(void) { |
MasudaToshio | 0:af120baf5a2e | 23 | Base::add_rpc_class<DigitalOut>(); |
MasudaToshio | 0:af120baf5a2e | 24 | lcd.cls(); |
MasudaToshio | 0:af120baf5a2e | 25 | lcd.locate(0,0); |
MasudaToshio | 0:af120baf5a2e | 26 | lcd.printf("Program init.. "); |
MasudaToshio | 1:89479d6c8b09 | 27 | |
MasudaToshio | 0:af120baf5a2e | 28 | if (ethif.setup()) { |
MasudaToshio | 0:af120baf5a2e | 29 | error("Ethernet setup failed."); |
MasudaToshio | 0:af120baf5a2e | 30 | return 1; |
MasudaToshio | 0:af120baf5a2e | 31 | } |
MasudaToshio | 1:89479d6c8b09 | 32 | |
MasudaToshio | 0:af120baf5a2e | 33 | IpAddr ethIp=ethif.getIp(); |
MasudaToshio | 0:af120baf5a2e | 34 | lcd.locate(0,1); |
MasudaToshio | 0:af120baf5a2e | 35 | lcd.printf("%d.%d.%d.%d", ethIp[0], ethIp[1], ethIp[2], ethIp[3]); |
MasudaToshio | 0:af120baf5a2e | 36 | led1=1; |
MasudaToshio | 0:af120baf5a2e | 37 | wait(1); |
MasudaToshio | 1:89479d6c8b09 | 38 | |
MasudaToshio | 0:af120baf5a2e | 39 | server.addHandler<SimpleHandler>("/hello"); |
MasudaToshio | 0:af120baf5a2e | 40 | server.addHandler<RPCHandler>("/rpc"); |
MasudaToshio | 0:af120baf5a2e | 41 | FSHandler::mount("/local", "/"); |
MasudaToshio | 0:af120baf5a2e | 42 | server.addHandler<FSHandler>("/"); |
MasudaToshio | 0:af120baf5a2e | 43 | server.bind(80); |
MasudaToshio | 1:89479d6c8b09 | 44 | |
MasudaToshio | 0:af120baf5a2e | 45 | while (1) { |
MasudaToshio | 0:af120baf5a2e | 46 | Net::poll(); |
MasudaToshio | 0:af120baf5a2e | 47 | } |
MasudaToshio | 0:af120baf5a2e | 48 | return 0; |
MasudaToshio | 0:af120baf5a2e | 49 | } |
MasudaToshio | 0:af120baf5a2e | 50 | |
MasudaToshio | 1:89479d6c8b09 | 51 | ///////////////////////////////////////////////////// |
MasudaToshio | 1:89479d6c8b09 | 52 | // LCD |
MasudaToshio | 1:89479d6c8b09 | 53 | ///////////////////////////////////////////////////// |
MasudaToshio | 1:89479d6c8b09 | 54 | void LcdWrite(char *input , char *output) { |
MasudaToshio | 1:89479d6c8b09 | 55 | lcd.cls(); |
MasudaToshio | 1:89479d6c8b09 | 56 | lcd.locate(0,0); |
MasudaToshio | 1:89479d6c8b09 | 57 | lcd.printf("%s",input); |
MasudaToshio | 0:af120baf5a2e | 58 | } |