Marutsu mbed seminar 11-09-2010

Dependencies:   EthernetNetIf mbed

Files at this revision

API Documentation at this revision

Comitter:
nxpfan
Date:
Sat Sep 11 08:19:56 2010 +0000
Commit message:

Changed in this revision

EthernetNetIf.lib Show annotated file Show diff for this revision Revisions of this file
HTTPClient.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
TwitterExample.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 2a57fec4e078 EthernetNetIf.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetNetIf.lib	Sat Sep 11 08:19:56 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/EthernetNetIf/#bc7df6da7589
diff -r 000000000000 -r 2a57fec4e078 HTTPClient.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient.lib	Sat Sep 11 08:19:56 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/HTTPClient/#d97a4fc01c86
diff -r 000000000000 -r 2a57fec4e078 TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Sat Sep 11 08:19:56 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
diff -r 000000000000 -r 2a57fec4e078 TwitterExample.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TwitterExample.cpp	Sat Sep 11 08:19:56 2010 +0000
@@ -0,0 +1,67 @@
+/*
+  Update: 21-06-2010
+  The basic authentication service for twitter is going down at the end of the week.
+  To continue using that program, the code has been updated to use http://supertweet.net which acts as an API proxy.
+  Simply visit the website to setup your twitter account for this API.
+  See: http://www.supertweet.net/about/documentation
+*/
+
+#include "mbed.h"
+#include "EthernetNetIf.h"
+#include "HTTPClient.h"
+#include "TextLCD.h"
+
+TextLCD lcd(p24, p25, p26, p27, p28, p29); // rs, e, d0-d3
+//TextLCD     lcd( p24, p26, p27, p28, p29, p30 ); // rs, e, d0-d3
+
+EthernetNetIf eth; 
+
+int main() {
+
+  printf("Init\n");                           lcd.locate( 0, 0 );   lcd.printf("Init           ");
+  printf("\r\nSetting up...\r\n");            lcd.locate( 0, 0 );   lcd.printf("Setting up     ");
+  
+  EthernetErr ethErr = eth.setup();
+  if(ethErr)
+  {
+    printf("Error %d in setup.\n", ethErr);   lcd.locate( 0, 0 );   lcd.printf("error %d", ethErr);
+    return -1;
+  }
+  printf("\r\nSetup OK\r\n");                 lcd.locate( 0, 0 );   lcd.printf("Setup OK       ");
+
+  HTTPClient twitter;
+  
+  HTTPMap msg;
+  
+  //msg["status"] = "twitter test AAAA"; //A good example of Key/Value pair use with Web APIs
+  LocalFileSystem local("local");
+  char   s[256];
+  FILE   *fp;
+  
+  printf("\r\nreading a message file.\r\n");
+  
+  if(NULL == (fp = fopen("/local/tweet.txt","r")) ) {
+    printf("\r\nError: The message file cannot be accessed\r\n");  lcd.locate( 0, 0 );   lcd.printf("File access error");
+    return -1;
+  }
+  
+  fgets(s,256,fp);
+  fclose(fp);
+  
+  msg["status"] = s;      lcd.locate( 0, 0 );   lcd.printf("File read done ");
+  twitter.basicAuth("USER_ID", "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/statuses/update.xml", msg, NULL); 
+  if( r == HTTP_OK )
+  {
+    printf("Tweet sent with success!\n");      lcd.locate( 0, 0 );   lcd.printf("Done           ");
+  }
+  else
+  {
+    printf("Problem during tweeting, return code %d\n", r);lcd.locate( 0, 0 );   lcd.printf("Got error      ");
+  }
+  
+  return 0;
+
+}
diff -r 000000000000 -r 2a57fec4e078 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Sep 11 08:19:56 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/3944f1e2fa4f