peer to peer rx terminal

Dependencies:   ISL29011 libxDot-dev-mbed5-deprecated

Fork of peer-to-peer_rxtx by Natalia Requejo

Revision:
62:5a4266922385
Parent:
61:ebe1838a9301
--- a/main.cpp	Sat Mar 10 14:05:32 2018 +0000
+++ b/main.cpp	Thu Jun 07 23:48:49 2018 +0000
@@ -7,8 +7,8 @@
 #include <string>
 #include <vector>
 
-//#define PEER_TO_PEER_SAMPLE 1
- #define OTA
+#define PEER_TO_PEER_SAMPLE 1
+ //#define OTA
 using namespace mts;
 #if defined(PEER_TO_PEER_SAMPLE)
 static uint8_t network_address[] = { 0x01, 0x02, 0x03, 0x04 };
@@ -116,7 +116,7 @@
     //dot->resetNetworkSession();
     //dot->restoreNetworkSession();
     //dot->saveNetworkSession();
-    dot->setLogLevel(MTSLog::TRACE_LEVEL);
+    dot->setLogLevel(MTSLog::INFO_LEVEL);
     
  #if defined(PEER_TO_PEER_SAMPLE)
     // attach the custom events handler
@@ -177,37 +177,13 @@
     }
     logInfo("joined");
  
-    for (uint8_t i = 0; i < iterations; i++) {
-        send_data[0] = i;//Envio en que iteracion estoy
-        if ((ret = dot->send(send_data)) != mDot::MDOT_OK) {
-            logError("failed to send: [%d][%s]", ret, mDot::getReturnCodeString(ret).c_str());
-            send_failure++;
-        } else {
-            logInfo("send data: %s", Text::bin2hexString(send_data).c_str());
-            //La funcion RECV() No funciona en peer to peer. La ventana de tiempo en que esta abierto 
-            //el canal despues de hacer el send, para escuchar la respuesta es
-            //muy corta y seria muy dificil hacer la sincronizacion 
-            //En peer to peer el dispositivo nunca se pone en deep sleep y esta escuchando continumente.
-            //Por lo tanto la respuesta unicamente vendra a traves de un evento.
-            //Por el contrario cuando la comunicacion es OTA, con el gateway aqui si deberiamos obtener el mensaje.
-            if ((ret = dot->recv(recv_data)) != mDot::MDOT_OK) {
-                logError("failed to recv: [%d][%s]", ret, mDot::getReturnCodeString(ret).c_str());
-            } else {
-                logInfo("recv data: %s", Text::bin2hexString(recv_data).c_str());
-                if (recv_data == send_data) {
-                    recv++;
-                } else {
-                    recv_mismatch++;
-                }
-            }
-            recv_data.clear();
-        }
-        
+    while(1) {
+        std::string rxxdata = events.print();
         next_tx = dot->getNextTxMs() + 1;
-        logInfo("waiting %ld ms to transmit again", next_tx);
-        wait_ms(next_tx);
-        logInfo("waiting another %d seconds", wait_time);
-        wait(wait_time);
+        logInfo("Datos : %s", rxxdata);
+        wait_ms(5000);
+        logInfo("waiting data \n");
+        wait_ms(100);
     }
     
     logInfo("Version: %s", dot->getId().c_str());