test for RPC Function connect Eathernet and type URL following: http://mbedIP/rpc/led2/write 1 http://mbedIP/rpc/LedWink/run

Dependencies:   EthernetNetIf mbed HTTPServer

Files at this revision

API Documentation at this revision

Comitter:
mitsu6488
Date:
Wed Jun 08 14:00:37 2011 +0000
Commit message:

Changed in this revision

EthernetNetIf.lib Show annotated file Show diff for this revision Revisions of this file
HTTPClient.lib Show annotated file Show diff for this revision Revisions of this file
HTTPServer.lib Show annotated file Show diff for this revision Revisions of this file
RPCInterface.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 10339dff440b EthernetNetIf.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetNetIf.lib	Wed Jun 08 14:00:37 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/EthernetNetIf/#bc7df6da7589
diff -r 000000000000 -r 10339dff440b HTTPClient.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient.lib	Wed Jun 08 14:00:37 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/HTTPClient/#d0be6af2d1db
diff -r 000000000000 -r 10339dff440b HTTPServer.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPServer.lib	Wed Jun 08 14:00:37 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/HTTPServer/#d753966e4d97
diff -r 000000000000 -r 10339dff440b RPCInterface.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RPCInterface.lib	Wed Jun 08 14:00:37 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/MichaelW/code/RPCInterface/#a9e2c45097c8
diff -r 000000000000 -r 10339dff440b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jun 08 14:00:37 2011 +0000
@@ -0,0 +1,61 @@
+#include "mbed.h"
+#include "EthernetNetIf.h"
+#include "HTTPServer.h"
+#include "HTTPClient.h"
+#include "RPCFunction.h" 
+
+DigitalOut led1(LED1,"led1");
+DigitalOut led2(LED2,"led2");
+DigitalOut led3(LED3,"led3");
+DigitalOut led4(LED4,"led4");
+
+
+#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
+    
+    HTTPServer server;
+    LocalFileSystem local("local");
+
+    void LedWink(char *input,char *output);
+    RPCFunction rpcFunc(&LedWink, "LedWink");
+
+
+int main(void) {
+
+    Base::add_rpc_class<DigitalOut>();
+
+    if (ethif.setup()) {
+        error("Ethernet setup failed.");
+        return 1;
+    }
+    IpAddr ethIp=ethif.getIp();
+    
+    led1=1; //confirm Eathernet working
+    server.addHandler<RPCHandler>("/rpc");
+    FSHandler::mount("/local", "/");
+    server.addHandler<FSHandler>("/");
+    server.bind(80);
+    
+    while (1) {
+        Net::poll();
+    }
+    return 0;
+}
+
+void LedWink(char *input, char *output){
+    int i;
+    for(i=0;i<8;i++){
+        led4=!led4;
+        wait(0.2);
+    }
+    return;   
+}
\ No newline at end of file
diff -r 000000000000 -r 10339dff440b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Jun 08 14:00:37 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912