ethernet
Dependencies: EthernetInterface mbed-rtos mbed
Fork of TCPSocket_HelloWorld by
Revision 15:bc7fc13dc5f6, committed 2018-02-09
- Comitter:
- MohamadNazrin
- Date:
- Fri Feb 09 02:19:29 2018 +0000
- Parent:
- 14:72be2b8b7f24
- Child:
- 16:65255e25e5dc
- Commit message:
- ethernet connection static and dhcp configuration; output : ping
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed May 14 15:07:26 2014 +0000
+++ b/main.cpp Fri Feb 09 02:19:29 2018 +0000
@@ -1,31 +1,16 @@
#include "mbed.h"
#include "EthernetInterface.h"
+int main() {
+
+static const char* mbedIp = "192.168.137.2"; //IP
+static const char* mbedMask = "255.255.255.0"; // Mask
+static const char* mbedGateway = "192.168.137.1"; //Gateway
-int main() {
EthernetInterface eth;
- eth.init(); //Use DHCP
+ // eth.init(); //Use DHCP
+ eth.init(mbedIp,mbedMask,mbedGateway);
eth.connect();
printf("IP Address is %s\n", eth.getIPAddress());
-
- TCPSocketConnection sock;
- sock.connect("mbed.org", 80);
-
- char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt 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) {}
}
Mohamad Nazrin Napiah
