SimpleThing
Dependencies: EthernetInterface mbed-rtos mbed
Fork of TCPSocket_HelloWorld by
main.cpp
- Committer:
- ganeshgore
- Date:
- 2015-06-08
- Revision:
- 15:a15d0b575131
- Parent:
- 11:59dcefdda506
File content as of revision 15:a15d0b575131:
#include "mbed.h" #include "EthernetInterface.h" int main() { EthernetInterface eth; eth.init(); //Use DHCP eth.connect(); printf("IP Address is %s\n", eth.getIPAddress()); TCPSocketConnection sock; sock.connect("data.sparkfun.com", 80); char http_cmd[] = "GET /input/pw19y5K1J9ILGj3o8ObA?private_key=64e8m7gey8UNXgl69GZJ&variable1=10&variable2=12 HTTP/1.0\n\n"; sock.send_all(http_cmd, sizeof(http_cmd)-1); char buffer[300]; int ret; while (true) { ret = sock.receive(buffer, sizeof(buffer)-1); if (ret <= 0) break; buffer[ret] = '\0'; printf("Received %d chars from server:\n%s\n", ret, buffer); } sock.close(); eth.disconnect(); while(1) {} }