![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This is all about HelloWorld to send message to Twitter with proxy Server
Dependencies: WIZnetInterface mbed
Revision 0:43bcaa586f60, committed 2015-08-26
- Comitter:
- joon874
- Date:
- Wed Aug 26 08:28:28 2015 +0000
- Commit message:
- This is all about sending message to Twitter with proxy Server
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WIZnetInterface.lib Wed Aug 26 08:28:28 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/#3b64df29662f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Aug 26 08:28:28 2015 +0000 @@ -0,0 +1,77 @@ + +#include "mbed.h" +#include "EthernetInterface.h" + +#define TOKEN "3252156354-fG0b1utXYAg5IqeJNMSJFlenx1rgSRXm5wgk21l" + +int main() +{ + + int phy_link; + printf("wait a second...\r\n"); + uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x03, 0x04, 0x02}; + + EthernetInterface eth; + eth.init(mac_addr); //Use DHCP + + while(1) { + + eth.connect(); + + phy link + do { + phy_link = eth.ethernet_link(); + printf("..."); + wait(2); + } while(!phy_link); + printf("\r\n"); + + printf("IP Address is %s\r\n", eth.getIPAddress()); + + TCP socket connect + TCPSocketConnection sock; + sock.connect("arduino-tweet.appspot.com", 80); + + printf("connected\r\n"); + + char message[] = "test1234"; + + char len[10]; + char str[10]; + + int length = sizeof(message) - 1 + sizeof(TOKEN) - 1 + 14; + + printf("%d\r\n",length); + + + char *cmd1 = "POST http://arduino-tweet.appspot.com/update HTTP/1.0\r\nContent-Length:"; + char *cmd2 = "72"; + char *cmd3 = "\r\n\r\ntoken="; + char *cmd4 = TOKEN; + char *cmd5 = "&status="; + char *cmd6 = message; + char *cmd7 = "\r\n"; + + + char send_data[1024]; + char buffer[1024]; + sprintf(send_data, "%s%s%s%s%s%s%s", cmd1, cmd2, cmd3, cmd4, cmd5, cmd6, cmd7); + + sock.send_all(send_data, sizeof(send_data)-1); + + printf("%s\r\n",send_data); + printf("send message done\r\n"); + + sock.receive(buffer, sizeof(buffer)-1); + + printf("%s\r\n",buffer); + + sock.close(); + + eth.disconnect(); + + wait(70.0); + + }; + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Aug 26 08:28:28 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8ed44a420e5c \ No newline at end of file