uiil

Dependencies:   EthernetInterface mbed-rtos mbed

Revision:
0:55870e460ef6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Dec 13 20:01:15 2017 +0000
@@ -0,0 +1,56 @@
+#include "mbed.h"
+
+#include "rtos.h"
+
+#include "EthernetInterface.h"
+
+char* ip ="169.254.158.31";
+
+char* mask = "255.255.0.0";
+
+char* gate = NULL;
+Serial pc(USBTX, USBRX);
+
+int main() {
+    pc.printf("lmao1");
+    EthernetInterface eth1;
+    
+    pc.printf("lmao2");
+    
+    int errorconnect = -1;
+    
+    eth1.init();
+    
+    pc.printf("IP Address is %s\n", eth1.getIPAddress());
+    
+    while(errorconnect == -1){
+    errorconnect = eth1.connect(3000);
+    pc.printf("\n\nCONNECT COM RESPOSTA:%d",errorconnect);
+    }
+    
+    
+    TCPSocketConnection sock;
+    
+    pc.printf("lmao5");
+    int errch;
+    errch = sock.connect(ip, 5050);
+    
+    
+    pc.printf("conectou no socket com mensagem %d", errch);
+    
+    char buffer[300];
+    int ret;
+    while (true) {
+        ret = sock.receive(buffer, sizeof(buffer)-1);
+        if (ret <= 0)
+            break;
+        buffer[ret] = '\0';
+        pc.printf("Received %d chars from server:\n%s\n", ret, buffer);
+    }
+      
+    sock.close();
+    
+    eth1.disconnect();
+    
+    while(1) {}
+}