![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Programme + libraires serveur capteur web
Dependencies: EthernetNetIf Serveur_web_capteur mbed
Fork of HTTPServerExample by
Diff: HTTPServerExample.cpp
- Revision:
- 3:e851c29d398d
- Parent:
- 1:114e347434c1
--- a/HTTPServerExample.cpp Fri Jul 09 14:46:03 2010 +0000 +++ b/HTTPServerExample.cpp Tue Jul 03 12:02:59 2018 +0000 @@ -6,6 +6,9 @@ DigitalOut led2(LED2, "led2"); DigitalOut led3(LED3, "led3"); DigitalOut led4(LED4, "led4"); +PwmOut venti(p21,"venti"); +AnalogIn pot(p18, "capteur_temp"); + LocalFileSystem fs("webfs"); @@ -13,13 +16,15 @@ HTTPServer svr; int main() { + venti.period(0.001); Base::add_rpc_class<DigitalOut>(); + Base::add_rpc_class<DigitalIn>(); - printf("Setting up...\n"); + printf("Setting up...\n\r"); EthernetErr ethErr = eth.setup(); if(ethErr) { - printf("Error %d in setup.\n", ethErr); + printf("Error %d in setup.\n\r", ethErr); return -1; } printf("Setup OK\n"); @@ -30,26 +35,28 @@ svr.addHandler<SimpleHandler>("/hello"); svr.addHandler<RPCHandler>("/rpc"); svr.addHandler<FSHandler>("/files"); - svr.addHandler<FSHandler>("/"); //Default handler - //Example : Access to mbed.htm : http://a.b.c.d/mbed.htm or http://a.b.c.d/files/mbed.htm + svr.addHandler<FSHandler>("/"); + svr.addHandler<MyOwnHandler>("/rw"); + svr.bind(80); - printf("Listening...\n"); + printf("Listening...\n\r"); Timer tm; tm.start(); - //Listen indefinitely while(true) { + x=pot.read(); //déclaration d'une variable X pour lire la valeur avec la requete RW (alternatif) Net::poll(); if(tm.read()>.5) { - led1=!led1; //Show that we are alive + led1=!led1 tm.start(); + if(x>10){ led2=1; + }else{ + led2=0; + } } } - - return 0; - }