TCP/IP based digital io controller for operating DigitalsOuts and reading DigitalIns.
Dependencies: EthernetInterface NetworkAPI mbed-rtos mbed
Fork of NetRelais by
Revision 6:33b57f606f2b, committed 2012-07-17
- Comitter:
- NegativeBlack
- Date:
- Tue Jul 17 15:21:06 2012 +0000
- Parent:
- 5:01f6c3e112af
- Child:
- 7:c4ea5b5a7218
- Commit message:
- Simple hello world example doing a hostname lookup.
Changed in this revision
| NetworkAPI.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NetworkAPI.lib Tue Jul 17 15:21:06 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/NegativeBlack/code/NetworkAPI/#6956f6f96fef
--- 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
Roy van Dam
