SimpleThing
Dependencies: EthernetInterface mbed-rtos mbed
Fork of TCPSocket_HelloWorld by
main.cpp
00001 #include "mbed.h" 00002 #include "EthernetInterface.h" 00003 00004 int main() { 00005 EthernetInterface eth; 00006 eth.init(); //Use DHCP 00007 eth.connect(); 00008 printf("IP Address is %s\n", eth.getIPAddress()); 00009 00010 TCPSocketConnection sock; 00011 sock.connect("data.sparkfun.com", 80); 00012 00013 char http_cmd[] = "GET /input/pw19y5K1J9ILGj3o8ObA?private_key=64e8m7gey8UNXgl69GZJ&variable1=10&variable2=12 HTTP/1.0\n\n"; 00014 sock.send_all(http_cmd, sizeof(http_cmd)-1); 00015 00016 char buffer[300]; 00017 int ret; 00018 while (true) { 00019 ret = sock.receive(buffer, sizeof(buffer)-1); 00020 if (ret <= 0) 00021 break; 00022 buffer[ret] = '\0'; 00023 printf("Received %d chars from server:\n%s\n", ret, buffer); 00024 } 00025 00026 sock.close(); 00027 00028 eth.disconnect(); 00029 00030 while(1) {} 00031 }
Generated on Tue Jul 19 2022 01:07:01 by 1.7.2