PingPong demo using modtronix inAir9 module

Dependencies:   SX1276Lib_inAir mbed

Fork of SX1276PingPong by ENEL400

Revision:
15:916032fc76c0
Parent:
14:c7251480feb9
Child:
16:3d22f4dd0311
--- a/main.cpp	Wed Feb 17 09:28:29 2016 +0000
+++ b/main.cpp	Wed May 18 04:36:51 2016 +0000
@@ -1,10 +1,9 @@
 #include "mbed.h"
 #include "main.h"
 #include "sx1276-hal.h"
-#include "debug.h"
 
 /* Set this flag to '1' to display debug messages on the console */
-#define DEBUG_MESSAGE   0
+#define DEBUG_MESSAGE   1
 
 /* Set this flag to '1' to use the LoRa modulation or to '0' to use FSK modulation */
 #define USE_MODEM_LORA  1
@@ -100,7 +99,7 @@
     uint8_t i;
     bool isMaster = true;
     
-    debug( "\n\n\r     SX1276 Ping Pong Demo Application \n\n\r" );
+    printf( "\n\n\r     SX1276 Ping Pong Demo Application \n\n\r" );
 
     // Initialize Radio driver
     RadioEvents.TxDone = OnTxDone;
@@ -113,19 +112,14 @@
     // verify the connection with the board
     while( Radio.Read( REG_VERSION ) == 0x00  )
     {
-        debug( "Radio could not be detected!\n\r", NULL );
+        printf( "Radio could not be detected!\n\r" );
         wait( 1 );
     }
-            
-    debug_if( ( DEBUG_MESSAGE & ( Radio.DetectBoardType( ) == SX1276MB1LAS ) ) , "\n\r > Board Type: SX1276MB1LAS < \n\r" );
-    debug_if( ( DEBUG_MESSAGE & ( Radio.DetectBoardType( ) == SX1276MB1MAS ) ) , "\n\r > Board Type: SX1276MB1MAS < \n\r" );
+    printf("RadioRegVersion: %d\r\n", Radio.Read( REG_VERSION ));
     
     Radio.SetChannel( RF_FREQUENCY ); 
 
 #if USE_MODEM_LORA == 1
-    
-    debug_if( LORA_FHSS_ENABLED, "\n\n\r             > LORA FHSS Mode < \n\n\r");
-    debug_if( !LORA_FHSS_ENABLED, "\n\n\r             > LORA Mode < \n\n\r");
 
     Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
                          LORA_SPREADING_FACTOR, LORA_CODINGRATE,
@@ -140,8 +134,6 @@
                          LORA_IQ_INVERSION_ON, true );
                          
 #elif USE_MODEM_FSK == 1
-
-    debug("\n\n\r              > FSK Mode < \n\n\r");
     Radio.SetTxConfig( MODEM_FSK, TX_OUTPUT_POWER, FSK_FDEV, 0,
                          FSK_DATARATE, 0,
                          FSK_PREAMBLE_LENGTH, FSK_FIX_LENGTH_PAYLOAD_ON,
@@ -158,7 +150,7 @@
 
 #endif
      
-    debug_if( DEBUG_MESSAGE, "Starting Ping-Pong loop\r\n" ); 
+    printf( "Starting Ping-Pong loop\r\n" ); 
         
     led = 0;
         
@@ -176,7 +168,7 @@
                     if( strncmp( ( const char* )Buffer, ( const char* )PongMsg, 4 ) == 0 )
                     {
                         led = !led;
-                        debug( "...Pong\r\n" );
+                        printf( "...Pong\r\n" );
                         // Send the next PING frame            
                         strcpy( ( char* )Buffer, ( char* )PingMsg );
                         // We fill the buffer with numbers for the payload 
@@ -189,7 +181,7 @@
                     }
                     else if( strncmp( ( const char* )Buffer, ( const char* )PingMsg, 4 ) == 0 )
                     { // A master already exists then become a slave
-                        debug( "...Ping\r\n" );
+                        printf( "...Ping\r\n" );
                         led = !led;
                         isMaster = false;
                         // Send the next PONG frame            
@@ -216,7 +208,7 @@
                     if( strncmp( ( const char* )Buffer, ( const char* )PingMsg, 4 ) == 0 )
                     {
                         led = !led;
-                        debug( "...Ping\r\n" );
+                        printf( "...Ping\r\n" );
                         // Send the reply to the PING string
                         strcpy( ( char* )Buffer, ( char* )PongMsg );
                         // We fill the buffer with numbers for the payload 
@@ -240,11 +232,11 @@
             led = !led; 
             if( isMaster == true )  
             {
-                debug( "Ping...\r\n" );
+                printf( "Ping...\r\n" );
             }
             else
             {
-                debug( "Pong...\r\n" );
+                printf( "Pong...\r\n" );
             }
             Radio.Rx( RX_TIMEOUT_VALUE );
             State = LOWPOWER;
@@ -310,7 +302,7 @@
 {
     Radio.Sleep( );
     State = TX;
-    debug_if( DEBUG_MESSAGE, "> OnTxDone\n\r" );
+    printf( "> OnTxDone\n\r" );
 }
 
 void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr)
@@ -321,14 +313,14 @@
     RssiValue = rssi;
     SnrValue = snr;
     State = RX;
-    debug_if( DEBUG_MESSAGE, "> OnRxDone\n\r" );
+    printf( "> OnRxDone\n\r" );
 }
 
 void OnTxTimeout( void )
 {
     Radio.Sleep( );
     State = TX_TIMEOUT;
-    debug_if( DEBUG_MESSAGE, "> OnTxTimeout\n\r" );
+    printf( "> OnTxTimeout\n\r" );
 }
 
 void OnRxTimeout( void )
@@ -336,13 +328,13 @@
     Radio.Sleep( );
     Buffer[ BufferSize ] = 0;
     State = RX_TIMEOUT;
-    debug_if( DEBUG_MESSAGE, "> OnRxTimeout\n\r" );
+    printf( "> OnRxTimeout\n\r" );
 }
 
 void OnRxError( void )
 {
     Radio.Sleep( );
     State = RX_ERROR;
-    debug_if( DEBUG_MESSAGE, "> OnRxError\n\r" );
+    printf( "> OnRxError\n\r" );
 }