Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface HTTPClient NTPClient mbed-rtos mbed
Fork of HTTPClient_HelloWorld by
Revision 3:9c0e1bc428ea, committed 2014-03-18
- Comitter:
- nameless129
- Date:
- Tue Mar 18 16:05:43 2014 +0000
- Parent:
- 2:270e2d0bb85a
- Commit message:
- Use StewGate sample
Changed in this revision
--- a/EthernetInterface.lib Thu Aug 30 15:42:06 2012 +0000 +++ b/EthernetInterface.lib Tue Mar 18 16:05:43 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/EthernetInterface/#a0ee3ae75cfa +http://mbed.org/users/mbed_official/code/EthernetInterface/#6a67d2bddc7c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NTPClient.lib Tue Mar 18 16:05:43 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/donatien/code/NTPClient/#881559865a93
--- a/main.cpp Thu Aug 30 15:42:06 2012 +0000
+++ b/main.cpp Tue Mar 18 16:05:43 2014 +0000
@@ -1,37 +1,57 @@
#include "mbed.h"
#include "EthernetInterface.h"
#include "HTTPClient.h"
+#include "NTPClient.h"
+#include <time.h>
+#include <locale.h>
+Serial pc(USBTX, USBRX); // tx, rx
EthernetInterface eth;
HTTPClient http;
+NTPClient ntp;
char str[512];
+char JSTTime[128];
int main()
{
eth.init(); //Use DHCP
+ eth.connect();
+ printf("IP Address is %s\n", eth.getIPAddress());
- eth.connect();
-
- //GET data
- printf("\nTrying to fetch page...\n");
- int ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", str, 128);
- if (!ret)
+ printf("Trying to update time...\r\n");
+ if (ntp.setTime("0.pool.ntp.org") == 0)
{
- printf("Page fetched successfully - read %d characters\n", strlen(str));
- printf("Result: %s\n", str);
+ printf("Set time successfully\r\n");
+ time_t ctTime;
+ ctTime = time(NULL);
+ ctTime += 32400; //Conv UTC to JST
+ sprintf(JSTTime,"%s", ctime(&ctTime));
+ printf("%s",JSTTime);
}
else
{
- printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
- }
-
- //POST data
+ printf("Error\r\n");
+ }
HTTPMap map;
HTTPText inText(str, 512);
- map.put("Hello", "World");
- map.put("test", "1234");
- printf("\nTrying to post data...\n");
- ret = http.post("http://httpbin.org/post", map, &inText);
+/******************************************************/
+//Input your StewGate Token
+/******************************************************/
+ const char StewGate_Token[] = "";
+ map.put("_t", StewGate_Token);
+/****************************************/
+// Switch Get Tweet or Post Tweet
+/****************************************/
+#if 0
+ printf("\nTrying to Get Tweet\n");
+ int ret = http.post("http://stewgate-u.appspot.com/api/last_mention/", map, &inText);
+#else
+ char PostTweet[512];
+ sprintf(PostTweet,"test in mbed %s",JSTTime);
+ map.put("msg", PostTweet);
+ printf("\nTrying to Post Tweet\n");
+ int ret = http.post("http://stewgate-u.appspot.com/api/post/", map, &inText);
+#endif
if (!ret)
{
printf("Executed POST successfully - read %d characters\n", strlen(str));
@@ -40,38 +60,7 @@
else
{
printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
- }
-
- //PUT data
- strcpy(str, "This is a PUT test!");
- HTTPText outText(str);
- //HTTPText inText(str, 512);
- printf("\nTrying to put resource...\n");
- ret = http.put("http://httpbin.org/put", outText, &inText);
- if (!ret)
- {
- printf("Executed PUT successfully - read %d characters\n", strlen(str));
- printf("Result: %s\n", str);
- }
- else
- {
- printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
- }
-
- //DELETE data
- //HTTPText inText(str, 512);
- printf("\nTrying to delete resource...\n");
- ret = http.del("http://httpbin.org/delete", &inText);
- if (!ret)
- {
- printf("Executed DELETE successfully - read %d characters\n", strlen(str));
- printf("Result: %s\n", str);
- }
- else
- {
- printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
- }
-
+ }
eth.disconnect();
while(1) {
--- a/mbed-rtos.lib Thu Aug 30 15:42:06 2012 +0000 +++ b/mbed-rtos.lib Tue Mar 18 16:05:43 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#9654a71f5a90 +http://mbed.org/users/mbed_official/code/mbed-rtos/#710466f5cf33
--- a/mbed.bld Thu Aug 30 15:42:06 2012 +0000 +++ b/mbed.bld Tue Mar 18 16:05:43 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/976df7c37ad5 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/8e73be2a2ac1 \ No newline at end of file
