![](/media/cache/profiles/DG_Mugshot.png.50x50_q85.jpg)
Dependencies: EthernetNetIf mbed
Diff: main.cpp
- Revision:
- 0:c292522f5311
- Child:
- 2:2d0011b9bb1e
diff -r 000000000000 -r c292522f5311 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jun 17 09:21:41 2010 +0000 @@ -0,0 +1,40 @@ +// RFID Tweeter + +#include "mbed.h" +#include "ID12RFID.h" +#include "EthernetNetIf.h" +#include "HTTPClient.h" + +#define TWITTER_USER "donatiengarnier" +#define TWITTER_PASSWORD "myverysecurepassword" + +#define IDS_COUNT 3 +const int ids_list[IDS_COUNT] = {89481809, 89481810, 89481811}; +const char* names_list[IDS_COUNT] = {"Donatien", "Simon", "Dan"}; + +EthernetNetIf ethernet; +HTTPClient twitter; + +ID12RFID rfid(p14); +DigitalOut tag_present(LED1); +DigitalOut tweet_ok(LED4); + +int main() { + ethernet.setup(); + twitter.basicAuth(TWITTER_USER, TWITTER_PASSWORD); + + while(true) { + int id = rfid.read(); + tag_present = 1; + for(int i = 0; i < IDS_COUNT; i++) { + if (ids_list[i] == id) { + HTTPMap msg; + msg["status"] = names_list[i]; + msg["status"] += " just arrived home!"; + HTTPResult r = twitter.post("http://twitter.com/statuses/update.xml", msg, NULL); + tweet_ok = !r; + } + } + tag_present = 0; + } +}