Andriy Makukha / Mbed 2 deprecated football_project_wo_output

Dependencies:   mbed

Fork of football_project by MZJ

Revision:
70:bd4b1e19a0c6
Parent:
69:a3295b74209e
Child:
73:ac3588017e32
diff -r a3295b74209e -r bd4b1e19a0c6 Radio.cpp
--- a/Radio.cpp	Fri Feb 12 21:13:14 2016 +0000
+++ b/Radio.cpp	Mon Feb 22 09:48:42 2016 +0000
@@ -265,7 +265,7 @@
               em.mac |= (int)radio.DATA[7] << 8;
               em.mac |= (int)radio.DATA[6] << 16;
               em.mac |= (int)radio.DATA[5] << 24;
-            
+
               if( Dbg )  writeToPhone("RP: 0x%x\r\n", em.mac);
             
               if (em.mac != my_mac)
@@ -273,7 +273,7 @@
                   if( Dbg )  writeToPhone("DM 0x%x\r\n", em.mac);
                   break; // This message was meant for someone else
               }
-            
+
               memcpy(&em.m, &lm, sizeof(Message));
               slave_process(&em);                
           }
@@ -327,7 +327,7 @@
     if( RF69_MODE_RX != radio._mode )
     {
         // Either do this or change the setMode in RFM69.cpp at end of sendFrame() to  setMode(RF69_MODE_RX);
-        radio.receiveDone();  //// Prevent radio from going to standby or sleep. (Should never return true here.)
+        while( radio.receiveDone() );  //// Prevent radio from going to standby or sleep. (Shouldn't return true here.)
     }
 }
 
@@ -340,10 +340,25 @@
 
 bool radio_ack_received( int cone )
 {
-    bool retval = radio.ACKReceived(cone);
+////bool retval = radio.ACKReceived(cone);
+    bool retval = radio.receiveDone();
+
+    if( !get_crc_ok() )
+    {
+        writeToPhone( "BAD-CRC on ACK wait\r\n" );
+        retval = false;
+    }
 
     if( retval )
     {
+        if( !((radio.SENDERID == cone || cone == RF69_BROADCAST_ADDR) && radio.ACK_RECEIVED) )////...
+        {
+            // Got something that wasn't expected ACK.  (Paranoia--Haven't seen this happen yet.)
+            RA_DEBUG( "Got '%c', not ACK!\r\n", (char)radio.DATA[0] );
+            RA_DEBUG( "Wanted from %u, got from %u\r\n", cone, radio.SENDERID );
+            retval = false;
+        }
+
         if( radio.TARGETID == datastore_node_id() )
         {
             stompage_check();