Twitter for GSwifi see: http://mbed.org/users/gsfan/notebook/gainspan_wifi/
Dependencies: GSwifi (old) mbed
main.cpp
00001 #include "mbed.h" 00002 #include "GSwifi.h" 00003 00004 #define SECURE GSSEC_WPA_PSK 00005 #define SSID "SSID" 00006 #define PASS "passkey" 00007 00008 #define TWITTER "Tweet%20from%20GainSpan%20Wi-Fi" 00009 #define HTTP_HOST "api.supertweet.net" // SuperTweet.net 00010 // #define HTTP_HOST "twitter-basicauth.appspot.com" // TOBASIC! 00011 #define HTTP_URI "/1/statuses/update.xml" 00012 #define HTTP_USER "username" 00013 #define HTTP_PASS "password" 00014 00015 GSwifi gs(p13, p14); // TX, RX (no flow control) 00016 // GSwifi gs(p13, p14, p12, P0_22); // TX, RX, CTS, RTS 00017 Serial pc(USBTX, USBRX); 00018 DigitalOut led1(LED1), led2(LED2); 00019 00020 void onGsReceive (int cid, int len) { 00021 int i; 00022 char buf[GS_DATA_SIZE + 1]; 00023 00024 led2 = 1; 00025 i = gs.recv(cid, buf, len); 00026 buf[i] = 0; 00027 pc.printf(buf); 00028 } 00029 00030 int main () { 00031 int r; 00032 IpAddr ipaddr, netmask, gateway, nameserver; 00033 Host host; 00034 char msg[] = "status=" TWITTER; 00035 00036 led1 = 1; 00037 pc.baud(115200); 00038 00039 pc.printf("connect\r\n"); 00040 if (gs.connect(SECURE, SSID, PASS, 0)) { 00041 return -1; 00042 } 00043 gs.getAddress(ipaddr, netmask, gateway, nameserver); 00044 pc.printf("ip %d.%d.%d.%d\r\n", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]); 00045 00046 pc.printf("httpPost\r\n"); 00047 host.setName(HTTP_HOST); 00048 r = gs.httpPost(host, HTTP_URI, msg, HTTP_USER, HTTP_PASS, 0, &onGsReceive); 00049 if (r >= 0) { 00050 for (;;) { 00051 gs.poll(); 00052 if (! gs.isConnected(r)) break; 00053 00054 wait_ms(50); 00055 led1 = !led1; 00056 led2 = 0; 00057 } 00058 } 00059 00060 pc.printf("exit\r\n"); 00061 }
Generated on Thu Jul 21 2022 06:06:29 by 1.7.2