Twitter client that can be directly tweet. (Intermediate server is not required.)
Dependencies: EthernetInterface HTTPClient-wolfSSL NTPClient OAuth4Tw mbed-rtos mbed wolfSSL
Fork of OAuth4Tw by
Revision 2:392b8e079c7a, committed 2015-02-01
- Comitter:
- ban4jp
- Date:
- Sun Feb 01 17:39:08 2015 +0000
- Parent:
- 1:4dfa9d41f414
- Child:
- 3:5635abaf69f5
- Commit message:
- Update library.; Fixed the NTP processing.
Changed in this revision
--- a/EthernetInterface.lib Sun Dec 14 08:08:14 2014 +0000 +++ b/EthernetInterface.lib Sun Feb 01 17:39:08 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/users/mbed_official/code/EthernetInterface/#de796e2a5e98 +http://developer.mbed.org/users/mbed_official/code/EthernetInterface/#d1ccbed7687a
--- a/NTPClient.lib Sun Dec 14 08:08:14 2014 +0000 +++ b/NTPClient.lib Sun Feb 01 17:39:08 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/users/ban4jp/code/NTPClient/#c70ed0bfab2e +http://developer.mbed.org/users/ban4jp/code/NTPClient/#15c04f752381
--- a/OAuth4Tw.lib Sun Dec 14 08:08:14 2014 +0000 +++ b/OAuth4Tw.lib Sun Feb 01 17:39:08 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/users/ban4jp/code/OAuth4Tw/#0036880e6f71 +http://developer.mbed.org/users/ban4jp/code/OAuth4Tw/#a057c813fb02
--- a/main.cpp Sun Dec 14 08:08:14 2014 +0000 +++ b/main.cpp Sun Feb 01 17:39:08 2015 +0000 @@ -34,18 +34,45 @@ printf("Trying to update time...\n"); - //ret = ntp.setTime("pool.ntp.org"); - ret = ntp.setTime("ntp.nict.jp"); - if (!ret) { - time_t ctTime = time(NULL); - printf("Time is set to (UTC): %s\n", ctime(&ctTime)); - } else { - printf("Error\n"); + time_t ctTime; + NTPResult result; + + while(1) { + result = ntp.setTime("pool.ntp.org"); + //result = ntp.setTime("pool.ntp.org", NTP_DEFAULT_PORT, 2000); + + if (result == NTP_OK) { + time(&ctTime); + printf("Time is set to (UTC): %s\n", ctime(&ctTime)); + break; + } + + switch (result) { + case NTP_CONN: ///<Connection error + printf("Connection error\n"); + break; + case NTP_TIMEOUT: ///<Connection timeout + printf("Connection timeout\n"); + break; + case NTP_PRTCL: ///<Protocol error + printf("Protocol error\n"); + break; + case NTP_DNS: ///<Could not resolve name + printf("Could not resolve name\n"); + break; + default: + printf("Error result=%d\n", result); + return -1; + } + + wait(5); } std::string uri = "https://api.twitter.com/1.1/statuses/update.json"; uri += "?status="; uri += OAuth4Tw::url_escape("Hello World!"); + uri += OAuth4Tw::url_escape(" - "); + uri += OAuth4Tw::url_escape(ctime(&ctTime)); std::string postarg; std::string postres = oa4t.post(uri.c_str(), postarg); printf("postres: %s\n", postres.c_str());
--- a/mbed-rtos.lib Sun Dec 14 08:08:14 2014 +0000 +++ b/mbed-rtos.lib Sun Feb 01 17:39:08 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/users/mbed_official/code/mbed-rtos/#f1ef95efa5ad +http://developer.mbed.org/users/mbed_official/code/mbed-rtos/#5448826aa700