This program post the tweet with random number. It make random seed with open analog pin. On your try, please change username and password for your accounts.

Dependencies:   mbed lwip

Files at this revision

API Documentation at this revision

Comitter:
utaani
Date:
Tue Dec 01 12:43:27 2009 +0000
Commit message:

Changed in this revision

lwip.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r aa8f8270834a lwip.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lwip.lib	Tue Dec 01 12:43:27 2009 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_unsupported/code/lwip/
\ No newline at end of file
diff -r 000000000000 -r aa8f8270834a main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Dec 01 12:43:27 2009 +0000
@@ -0,0 +1,49 @@
+// twitter client test
+// written by utaani@ueno.org
+
+#include "mbed.h"
+#include "HTTPClient.h"
+#define DEBUG
+
+DigitalOut led(LED1);    // for finised indicator
+HTTPClient http;         // twitter client
+
+#ifdef DEBUG
+Serial pc(USBTX, USBRX); // for debug
+#endif
+
+AnalogIn seed(p15);      // for random seed
+
+const char user[] = "username";
+const char pass[] = "password";
+const char url[]  = "http://twitter.com/statuses/update.xml";
+
+int main(void) {
+    char response[4096]; // buffer for results
+    char msg[1024];      // buffer for messages
+    int  result,i;
+    
+    srand(seed.read_u16()); // init random with AnalogIn (for multipul post)
+    sprintf(msg, "status=This is test from mbed.(%d)", rand()%100); // make message
+
+    #ifdef DEBUG
+    pc.printf("started\r\n"); 
+    #endif
+
+    http.auth(user, pass);
+    result = http.post(url, msg, response, 4096);
+
+    #ifdef DEBUG
+    pc.printf("result=%d\r\n",result);
+    for(i=0;i<result;i++) {
+     pc.putc(response[i]);
+    }
+    pc.printf("\r\n");
+    #endif    
+
+    // finished loop
+    while(1) {
+        led = !led;
+        wait(0.2);
+    }
+}
diff -r 000000000000 -r aa8f8270834a mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Dec 01 12:43:27 2009 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/32af5db564d4