Un serveur web embarqué pour mbed, commande de leds, lecture potentiometre en utilisant rpc.

Dependencies:   EthernetNetIf HTTPServer RPCInterface mbed

Fork of HTTPServerExample by Donatien Garnier

Pour fonctionner correctement, il est nécessaire de placer un fichier nommé index.htm (page html + javascript) dans la mémoire du mbed. Voici le fichier que j'ai utilisé

/media/uploads/LouisReynier/index.htm

Files at this revision

API Documentation at this revision

Comitter:
LouisReynier
Date:
Thu Apr 06 18:56:46 2017 +0000
Parent:
2:f8e64bf9a474
Commit message:
Une version de serveur mbed embarqu? qui commande 1 led et qui lit un potentiometre + variable temps.

Changed in this revision

HTTPServerExample.cpp 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
--- a/HTTPServerExample.cpp	Fri Jul 09 14:46:03 2010 +0000
+++ b/HTTPServerExample.cpp	Thu Apr 06 18:56:46 2017 +0000
@@ -1,11 +1,20 @@
 #include "mbed.h"
 #include "EthernetNetIf.h"
 #include "HTTPServer.h"
+#include "SerialRPCInterface.h"
+
+// LR 2/2/17
+// sur ce fichier j'ai rajouté une variable RPC count que je peux lire à distance
+// adresse/rpc/count/read/
 
 DigitalOut led1(LED1, "led1");
 DigitalOut led2(LED2, "led2");
 DigitalOut led3(LED3, "led3");
 DigitalOut led4(LED4, "led4");
+AnalogIn Pot1(p19, "pot1");
+
+int count = 0 ;
+RPCVariable<int> rpc_count(&count, "count");
 
 LocalFileSystem fs("webfs");
 
@@ -16,6 +25,14 @@
   Base::add_rpc_class<DigitalOut>();
 
   printf("Setting up...\n");
+  
+  // modif LR config IP manuelle sinon dhcp !
+  EthernetNetIf eth( IpAddr(192,168,1,102), // IP
+                     IpAddr(255,255,255,0), // Subnet mask
+                     IpAddr(192,168,1,1),   // Gateway
+                     IpAddr(192,168,1,1) ); // DNS
+                     
+                     
   EthernetErr ethErr = eth.setup();
   if(ethErr)
   {
@@ -23,11 +40,11 @@
     return -1;
   }
   printf("Setup OK\n");
-  
+  // on définit où seront stockés les fichiers !
   FSHandler::mount("/webfs", "/files"); //Mount /webfs path on /files web path
   FSHandler::mount("/webfs", "/"); //Mount /webfs path on web root path
   
-  svr.addHandler<SimpleHandler>("/hello");
+  svr.addHandler<SimpleHandler>("/hello"); // http://a.b.c.d/hello : hello world !
   svr.addHandler<RPCHandler>("/rpc");
   svr.addHandler<FSHandler>("/files");
   svr.addHandler<FSHandler>("/"); //Default handler
@@ -46,6 +63,7 @@
     if(tm.read()>.5)
     {
       led1=!led1; //Show that we are alive
+      count ++ ;
       tm.start();
     }
   }
@@ -53,3 +71,4 @@
   return 0;
 
 }
+// http://192.168.1.102/rpc/pot1/read dans le navigateur permet de lire l'état du potard !
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RPCInterface.lib	Thu Apr 06 18:56:46 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/hexley/code/RPCInterface/#1c61049a0349