GPS Tweeter program that tweets the device's GPS location every 5 minutes.
Dependencies: EthernetNetIf HTTPClient mbed
Fork of TwitterExample by
Diff: main.cpp
- Revision:
- 5:22fb0d9a5de2
- Parent:
- 4:2d5b7c5b995e
- Child:
- 6:a5d8918748fa
diff -r 2d5b7c5b995e -r 22fb0d9a5de2 main.cpp --- a/main.cpp Wed Oct 16 20:32:46 2013 +0000 +++ b/main.cpp Wed Oct 16 20:40:55 2013 +0000 @@ -7,20 +7,18 @@ GPS gps(p13, p14); int main() { - // Setup the time structure - + // Setup the time structure char buff[141]; printf("Initialization in Process\n"); - EthernetErr ethErr = eth.setup(180000); + EthernetErr ethErr = eth.setup(60000); if(ethErr) { printf("Error %d in setup.\n", ethErr); return -1; } printf("\r\nSetup OK\r\n"); - //wait(45); // Setup objects for sending the tweet. HTTPClient twitter; @@ -33,9 +31,8 @@ if(gps.sample()) { printf("I'm at %f, %f\n\r", gps.longitude, gps.latitude); sprintf(buff,"I'm at %f, %f", gps.longitude, gps.latitude); - //sprintf(buff,"Hey Guys, today I decided to take up a new hobby to cook. I will be making some amazing thing."); msg["status"] = buff; - twitter.basicAuth("4180SKRW", "welcome1"); //We use basic authentication, replace with you account's parameters + twitter.basicAuth("username", "password"); //We use basic authentication, replace with you account's parameters //No need to retieve data sent back by the server HTTPResult r = twitter.post("http://api.supertweet.net/1.1/statuses/update.json", msg, NULL); @@ -50,9 +47,9 @@ } else { printf("Oh Dear! No lock :(\n\r"); - sprintf(buff,"hello my name is richard"); + sprintf(buff,"Location Unknown"); msg["status"] = buff; - twitter.basicAuth("4180SKRW", "welcome1"); //We use basic authentication, replace with you account's parameters + twitter.basicAuth("username", "password"); //We use basic authentication, replace with you account's parameters //No need to retieve data sent back by the server HTTPResult r = twitter.post("http://api.supertweet.net/1.1/statuses/update.json", msg, NULL); @@ -66,7 +63,7 @@ } } - wait(60*5); + wait(60*5); //Repeat ever 5 minutes } return 0;