display your latest tweet with WiFly RN-XV and AD128160-UART
Dependencies: AD128160_kazushi_branch HTTPClient mbed PowerControl WiflyInterface
Fork of FontTest3 by
Please see at http://kazushi-lab.c.fun.ac.jp/pukiwiki/index.php?TwitterMbed
Diff: main.cpp
- Revision:
- 6:5aa67ed9ae43
- Parent:
- 4:d7a5f6fe7987
- Child:
- 8:22eb078985b1
--- a/main.cpp Wed Jan 09 07:37:50 2013 +0000 +++ b/main.cpp Sun Feb 10 06:02:51 2013 +0000 @@ -5,6 +5,8 @@ // refer to GingaX's notebook (http://www31.atwiki.jp/gingax/pages/63.html) #include "mbed.h" +#include "PowerControl/PowerControl.h" +#include "PowerControl/EthernetPowerControl.h" #include "GSwifi.h" #include "sjis_utf16.h" #include "s_Lcd.h" @@ -12,14 +14,14 @@ #define countof(x) ( sizeof(x) / sizeof(x[0]) ) #define SECURE GSSEC_WPA_PSK -#define SSID "SSID" -#define PASS "passkey" +#define SSID "mima-lab" +#define PASS "ikaika5656" #define HTTP_HOST "api.supertweet.net" // SuperTweet.net //#define HTTP_URI "/1.1/statuses/show.json?id=281639966776369152" #define HTTP_URI "/1.1/statuses/user_timeline.json?screen_name=pla3c&count=1" -#define HTTP_USER "username" -#define HTTP_PASS "password" +#define HTTP_USER "pla3c" +#define HTTP_PASS "pla3c" #define INTERVAL_SEC 60.0 //#define _DEBUG @@ -89,7 +91,9 @@ int connect(){ IpAddr ipaddr, netmask, gateway, nameserver; - if (gs.connect(SECURE, SSID, PASS, 0)) { + //gs.command("AT&F", GSRES_NORMAL); + + if (gs.connect(SECURE, SSID, PASS, 1, 5)) { drawString("WiFi connection error"); newline(); #ifdef _DEBUG pc.printf("WiFi connection error\r\n"); @@ -163,7 +167,11 @@ int r; char* msg; Host host; - led1 = 1; + led1 = 0; + + PHY_PowerDown(); + Peripheral_PowerDown(0x7D7F6FE1); + gs.setBaud(115200); #ifdef _DEBUG pc.baud(115200); #endif @@ -178,7 +186,7 @@ drawString((unsigned char*)msg); newline(); r = connect(); if(r<0){ - return -1; + NVIC_SystemReset(); } msg = "start twitter"; @@ -197,9 +205,11 @@ msg = "reconnect"; drawString((unsigned char*)msg); newline(); wait_ms(5); - connect(); + r = gs.disconnect(); + r = connect(); } wait(INTERVAL_SEC); } + }