Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface SensorsTointegrate mbed-rtos mbed
Fork of MainTaskGus by
Coments.cpp
00001 /* 00002 00003 TODO: 00004 00005 1.- Conectar a ambos servidores 00006 1.1 - si no solo conectar a uno y tener present la conección activa 00007 2.-hacer funciones para dvidir las cadenas de los mensajes 00008 3.-hace funcion para formar cadenas para enviar mensajes 00009 4. Formato de mensajes para que los pueda leer el server 00010 00011 */ 00012 00013 00014 /* 00015 00016 00017 00018 /* 00019 00020 // Receive message from server 00021 char buf1[256]; 00022 int n1 = socketTCP1.receive(buf1, 256); 00023 buf1[n1] = '\0'; 00024 00025 if(n1>0) { 00026 pc.printf("Received message from server1 IF: '%s'\n\r", buf1); 00027 socketTCP1.close(); 00028 //isConnectedServer1=false; 00029 } else { 00030 //_isConnectedServer1==false; //quiere decir que se desconecto del servidor 00031 pc.printf("Not received ELSE value of lenght: '%u'\n\r",strlen(buf1)); 00032 socketTCP1.close(); 00033 //isConnectedServer1=false; 00034 } 00035 00036 if(bo_somethingWrong==true) { 00037 return 0; 00038 } 00039 00040 //if(socketTCP.connect(ECHO_SERVER_ADDRESS1, ECHO_SERVER_PORT1) == -1 && _isConnectedServer1==false ) { 00041 if(socketTCP.connect(ECHO_SERVER_ADDRESS1, ECHO_SERVER_PORT1) == -1) { 00042 _isConnectedServer1=socketTCP.is_connected(); 00043 //_isConnectedServer1=false; 00044 pc.printf("Unable to connect to (%s) on port (%d)\n\r", ECHO_SERVER_ADDRESS1, ECHO_SERVER_PORT1); 00045 wait(1); 00046 } else { 00047 _isConnectedServer1=socketTCP.is_connected(); 00048 //_isConnectedServer1=true; 00049 //pc.printf("Connected to Server at %s\n\r",ECHO_SERVER_ADDRESS1); 00050 pc.printf("Connected to Server at %s\n\r",socketTCP.get_address()); 00051 pc.printf("Connected to PORT at %u\n\r",socketTCP.get_port()); 00052 00053 00054 00055 //TODO: split strings 00056 00057 char hello[] = "reply:get:status:192.168.1.77:door:1\n\r"; 00058 00059 pc.printf("Sending message to Server : %s \n\r",hello); 00060 socketTCP.send_all(hello, sizeof(hello)- 1); 00061 00062 00063 00064 // Receive message from server 00065 char buf[256]; 00066 int n = socketTCP.receive(buf, 256); 00067 buf[n] = '\0'; 00068 pc.printf("Received message from server: '%s'\n\r", buf); 00069 00070 if(bo_somethingWrong==true) { 00071 return 0; 00072 } 00073 00074 00075 } 00076 00077 00078 00079 } 00080 00081 // Clean up 00082 socketTCP1.close(); 00083 socketTCP2.close(); 00084 */ 00085 00086 00087 00088 // Send message to server 00089 /* 00090 strcat(s_myIP,"\n\r"); 00091 pc.printf("Sending message to Server : %s \n\r",s_myIP); 00092 socketTCP.send_all(s_myIP, sizeof(s_myIP) - 1); 00093 */ 00094 /* 00095 c_myIP = "192.168.1.77\n\r"; 00096 //strcat(c_myIP,"\n\r"); 00097 pc.printf("Sending message to Server : %s \n\r",c_myIP); 00098 socketTCP.send_all(c_myIP, sizeof(c_myIP) - 1); 00099 */ 00100 00101 //char hello[] = "reply:get:"; 00102 //char hello2[] = "status:192.168.1.77:door:1\n\r" ; 00103 //strcat(hello,hello2); 00104 00105 00106 //THREADS CSDECLARATION 00107 //Thread thread2(conect_Server); 00108 //Thread *thread2; 00109 //thread2 = new Thread(conect_Server); 00110 00111 00112 00113 00114 //IMPORT FROM LIBRARY 00115 /* 00116 cad = driver.echo(); 00117 pc.printf("libraryECHO: %s\n\r",cad); 00118 int var = driver.is_good(); 00119 pc.printf("libraryVAR: %u\n\r",var); 00120 */ 00121 00122
Generated on Fri Jul 15 2022 22:05:08 by
1.7.2
