A test program for my SuperTweet driver classes.
Dependencies: mbed SuperTweet EthernetNetIf
Revision 1:183d8c0ba30d, committed 2010-10-28
- Comitter:
- shintamainjp
- Date:
- Thu Oct 28 12:04:04 2010 +0000
- Parent:
- 0:67880614001c
- Child:
- 2:110af84baf48
- Commit message:
- Updated a test program for my SuperTweet driver classes.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extlib/EthernetNetIf.lib Thu Oct 28 12:04:04 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/donatien/code/EthernetNetIf/#bc7df6da7589
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extlib/HTTPClient.lib Thu Oct 28 12:04:04 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/donatien/code/HTTPClient/#d0be6af2d1db
--- a/main.cpp Wed Oct 13 10:56:38 2010 +0000 +++ b/main.cpp Thu Oct 28 12:04:04 2010 +0000 @@ -1,12 +1,59 @@ #include "mbed.h" +#include "EthernetNetIf.h" +#include "SuperTweetV1XML.h" + +#define YOUR_ACCOUNT "YOUR_ACCOUNT" +#define YOUR_PASSWORD "YOUR_PASSWORD" + +extern "C" void mbed_reset(); + +EthernetNetIf net; +SuperTweetV1XML st(YOUR_ACCOUNT, YOUR_PASSWORD); -DigitalOut myled(LED1); +/** + * Callback function for postStatusesUpdate. + * + * @param buf A pointer to a buffer. + * @param siz A size of the buffer. + */ +void func(char *buf, size_t siz) { +#if 0 + /* + * This is for checking a response. + */ + for (int i = 0; i < siz; i++) { + printf("%c", buf[i]); + } +#endif +} +/** + * Entry point. + */ int main() { - while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); + char text[BUFSIZ]; + int cnt = 0; + + EthernetErr err = net.setup(); + if (err) { + error("Network setup failed.\n"); + } + + while (1) { + snprintf(text, sizeof(text), "Hi! I'm mbed from ARM. Message number is %d", cnt++); + HTTPResult r = st.postStatusesUpdate(std::string(text), func); + printf("r=%d\n", (int)r); + + /* + * Note: + * I don't know why sometime it get a error. + * I think it a bug in a mbed library. + */ + if (r != 0) { + printf("Resetting...\n"); + mbed_reset(); + } + + wait(5); } }
--- a/mylib/SuperTweet.lib Wed Oct 13 10:56:38 2010 +0000 +++ b/mylib/SuperTweet.lib Thu Oct 28 12:04:04 2010 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/shintamainjp/code/SuperTweet/#d48d92e6c145 +http://mbed.org/users/shintamainjp/code/SuperTweet/#2d211e591fc8