TCPSocket_Ethernet modify
Dependencies: EthernetInterface2 mbed-rtos mbed
Fork of TCPSocket_HelloWorld by
Diff: main.cpp
- Revision:
- 15:d7e821422e97
- Parent:
- 11:59dcefdda506
--- a/main.cpp Wed May 14 15:07:26 2014 +0000 +++ b/main.cpp Tue May 30 16:07:41 2017 +0000 @@ -1,16 +1,19 @@ #include "mbed.h" #include "EthernetInterface.h" +Serial pc(USBTX, USBRX); + int main() { EthernetInterface eth; eth.init(); //Use DHCP - eth.connect(); - printf("IP Address is %s\n", eth.getIPAddress()); + int i = eth.connect(); + pc.printf("Connection = %d, ",i); + pc.printf("\nIP Address is %s -\nGateway: %s -\nMACAddress %s \n", eth.getIPAddress(),eth.getGateway(),eth.getMACAddress()); TCPSocketConnection sock; - sock.connect("mbed.org", 80); + sock.connect("www.unife.it", 80); - char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n"; + char http_cmd[] = "GET /ing/lm.infoauto HTTP/1.0\n\n"; sock.send_all(http_cmd, sizeof(http_cmd)-1); char buffer[300]; @@ -20,7 +23,7 @@ if (ret <= 0) break; buffer[ret] = '\0'; - printf("Received %d chars from server:\n%s\n", ret, buffer); + pc.printf("Received %d chars from server:\n%s\n", ret, buffer); } sock.close();