Basic MAC data interface for LoRa transceiver

Dependencies:   L2Frame crc

Dependents:   LoRaBaseStation LoRaTerminal

Revision:
18:3e6483550f25
Parent:
17:c6e2e2cd6e5f
Child:
19:6cd5024b6ae4
--- a/AlohaTransceiver.cpp	Thu Aug 11 02:37:30 2016 +0000
+++ b/AlohaTransceiver.cpp	Fri Aug 12 04:07:55 2016 +0000
@@ -1,9 +1,11 @@
 #include "AlohaTransceiver.h"
 #include "mbed.h"
 #include "radio.h"
+#include "debug.h"
 #include "AlohaFrame.h"
 #include "RingBuffer.h"
 
+
 // declear the type of radio state
 typedef enum
 {
@@ -107,10 +109,14 @@
     // verify the connection with the board
     while( Radio.Read( REG_VERSION ) == 0x00  )
     {
-        printf( "Radio could not be detected!\n\r" );
+#ifdef DEBUG_ALOHA
+        debug( "Radio could not be detected!\n\r" );
+#endif
         wait( 1 );
     }
+#ifdef DEBUG_ALOHA
     printf("RadioRegVersion: %d\r\n", Radio.Read( REG_VERSION ));
+#endif
 }
 
 void AlohaTransceiver::updateSettings()
@@ -314,7 +320,10 @@
 {
     Radio.Sleep( );
     State = TX;
-    printf( "> OnTxDone\n\r" );
+    
+#ifdef DEBUG_ALOHA
+    debug("> OnTxDone\n\r" );
+#endif
 }
 
 void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr)
@@ -328,14 +337,20 @@
     RssiValue = rssi;
     SnrValue = snr;
     State = RX;
-    printf( "> OnRxDone\n\r" );
+    
+#ifdef DEBUG_ALOHA
+    debug("> OnRxDone\n\r" );
+#endif
 }
 
 void OnTxTimeout( void )
 {
     Radio.Sleep( );
     State = TX_TIMEOUT;
-    printf( "> OnTxTimeout\n\r" );
+    
+#ifdef DEBUG_ALOHA
+    debug("> OnTxTimeout\n\r" );
+#endif
 }
 
 void OnRxTimeout( void )
@@ -343,12 +358,18 @@
     Radio.Sleep( );
     Buffer[ BufferSize ] = 0;
     State = RX_TIMEOUT;
-    printf( "> OnRxTimeout\n\r" );
+    
+#ifdef DEBUG_ALOHA
+    debug("> OnRxTimeout\n\r" );
+#endif
 }
 
 void OnRxError( void )
 {
     Radio.Sleep( );
     State = RX_ERROR;
-    printf( "> OnRxError\n\r" );
+    
+#ifdef DEBUG_ALOHA
+    debug( "> OnRxError\n\r" );
+#endif
 }