First commit
Dependencies: EthernetInterface FXAS21002 FXOS8700 NetworkAPI mbed-rtos mbed
Diff: main.cpp
- Revision:
- 6:33b57f606f2b
- Parent:
- 5:01f6c3e112af
- Child:
- 8:d55cac25e637
--- a/main.cpp Mon Jul 16 14:49:13 2012 +0000 +++ b/main.cpp Tue Jul 17 15:21:06 2012 +0000 @@ -1,35 +1,19 @@ #include "mbed.h" #include "EthernetInterface.h" -int main() -{ - EthernetInterface eth; - eth.init(); //Use DHCP - eth.connect(); - printf("IP Address is %s\n", eth.getIPAddress()); - - TCPSocket sock; - sock.connect("mbed.org", 80); - - char http_cmd[] = "GET /media/uploads/donatien/hello.txt HTTP/1.1\r\nHost: %s\r\n\r\n"; - sock.send(http_cmd, sizeof(http_cmd) - 1, 3000); +#include "NetworkAPI/ip/address.hpp" - char in_buf[256]; - bool firstIteration = true; - int ret; - do - { - ret = sock.receive(in_buf, 255, firstIteration?3000:0); - in_buf[ret] = '\0'; - - printf("Received %d chars from server: %s\n", ret, in_buf); - firstIteration = false; - } while( ret > 0 ); - - sock.close(); +int +main() +{ + EthernetInterface interface; + interface.init(); + interface.connect(); + printf("IP Address is %s\n\r", interface.getIPAddress()); + + network::ip::Address address; + address.fromHostname("www.google.nl"); - eth.disconnect(); - - while(1) { - } -} + printf("Network address %s\n", address.toString().c_str()); + return 0; +} \ No newline at end of file