Programa que publica mensajes en tu cuenta de Twitter cada vez que se reconoce un Tag RFID.
Dependencies: EthernetNetIf mbed HTTPClient ID12RFID
Revision 0:36befe9ffc69, committed 2012-08-13
- Comitter:
- angel_efrain
- Date:
- Mon Aug 13 17:16:33 2012 +0000
- Commit message:
- Programa para publicar mensajes en tu cuenta de Twitter autom?ticamente mediante un lector y Tags RFID
Changed in this revision
diff -r 000000000000 -r 36befe9ffc69 EthernetNetIf.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetNetIf.lib Mon Aug 13 17:16:33 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mamezu/code/EthernetNetIf/#0f6c82fcde82
diff -r 000000000000 -r 36befe9ffc69 HTTPClient.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HTTPClient.lib Mon Aug 13 17:16:33 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mamezu/code/HTTPClient/#62fac7f06c8d
diff -r 000000000000 -r 36befe9ffc69 ID12RFID.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ID12RFID.lib Mon Aug 13 17:16:33 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/ID12RFID/#f04afa911cf5
diff -r 000000000000 -r 36befe9ffc69 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Aug 13 17:16:33 2012 +0000 @@ -0,0 +1,90 @@ +//PARA PODER UTILIZARLO SE DEBE REALIZAR EL REGISTRO EN LA PÁGINA DE SUPERTWEET http://www.supertweet.net/ +//REALIZADO POR GALO BECERRA - TAS 2012 - ECUADOR + +#include "mbed.h" +#include "ID12RFID.h" +#include "EthernetNetIf.h" +#include "HTTPClient.h" + +#define TWITTER_USER "USER_NAME" +#define TWITTER_PASSWORD "PASWWORD" + +#define IDS_COUNT 3 +const int ids_list[IDS_COUNT] = {8984648, 9541172, 89481811}; +const char* names_list[IDS_COUNT] = {"Usuario1", "Usuario2", "Usuario3"}; + +EthernetNetIf ethernet; +HTTPClient twitter; + +ID12RFID rfid(p14); +DigitalOut tag_present(LED1); +PwmOut eth_status(LED2); +DigitalOut tweet_ok(LED4); + +int main() { + int contador=0; + char mensaje[BUFSIZ]; + + EthernetErr err = ethernet.setup(); + + if(err){ + eth_status = 1; + } + else{ + for(float x=0.0; x<1; x+=0.01){ + eth_status = x; + wait(0.03); + } + for(float x=1; x>0; x-=0.01){ + eth_status = x; + wait(0.03); + } + } + + twitter.basicAuth(TWITTER_USER, TWITTER_PASSWORD); + + while(true) { + int id = rfid.read(); + tag_present = 1; + contador++; + + for(int i=0; i<IDS_COUNT; i++){ + if (ids_list[i] == id){ + HTTPMap msg; + snprintf(mensaje, sizeof(mensaje), "Acceso de: %s numero: %u",names_list[i],contador); + msg["status"] = mensaje; + HTTPResult r = twitter.post("http://api.supertweet.net/1/statuses/update.xml", msg, NULL); + + if( r == HTTP_OK ){ + printf("Tweet sent with success!\n"); + for(int j=0; j<5; j++){ + tweet_ok = 1; + wait(0.1); + tweet_ok = 0; + wait(0.1); + } + } + else{ + printf("Problem during tweeting, return code %d\n", r); + tweet_ok = 1; + } + + } + } + tag_present = 0; + } +} + +//Código para leer los tag RFID +/*#include "mbed.h" +#include "ID12RFID.h" + +ID12RFID rfid (p14); +Serial pc (USBTX,USBRX); +int main() { +pc.printf("Tag ID = %d\n\r", 50); // Prints the RFID Tag into the Terminal + while (1){ + int id = rfid.read(); // Reads the RFID Tag + pc.printf("Tag ID = %d\n\r",id); // Prints the RFID Tag into the Terminal + } +}*/ \ No newline at end of file
diff -r 000000000000 -r 36befe9ffc69 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Aug 13 17:16:33 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/10b9abbe79a6 \ No newline at end of file