ping pong lora to coragem

Dependencies:   SX1272Lib

Revision:
15:b7402d36f0a3
Parent:
14:ab6eecd44b7a
--- a/main.cpp	Mon Apr 24 09:29:13 2017 +0000
+++ b/main.cpp	Thu Oct 15 20:39:26 2020 +0000
@@ -50,9 +50,9 @@
 #define BUFFER_SIZE                                     32        // Define the payload size here
 
 #if( defined ( TARGET_KL25Z ) || defined ( TARGET_LPC11U6X ) )
-DigitalOut led( LED2 );
+DigitalOut led( P1_13 );
 #else
-DigitalOut led( LED1 );
+DigitalOut led( P1_14 );
 #endif
 
 /*
@@ -100,7 +100,7 @@
     uint8_t i;
     bool isMaster = true;
 
-    debug( "\n\n\r     SX1272 Ping Pong Demo Application \n\n\r" );
+    debug_2( "\n\n\r     SX1272 Ping Pong Demo Application \n\n\r" );
 
     // Initialize Radio driver
     RadioEvents.TxDone = OnTxDone;
@@ -111,20 +111,20 @@
     Radio.Init( &RadioEvents );
 
     // verify the connection with the board
-    while( Radio.Read( REG_VERSION ) == 0x00  )
+    while( Radio.Read( REG_VERSION ) == 0xFF  )
     {
-        debug( "Radio could not be detected!\n\r", NULL );
+        debug_2( "Radio could not be detected!\n\r", NULL );
         wait( 1 );
     }
 
-    debug_if( ( DEBUG_MESSAGE & ( Radio.DetectBoardType( ) == SX1272MB2XAS ) ), "\n\r > Board Type: SX1272MB2xAS < \n\r" );
+    debug_if_2( ( DEBUG_MESSAGE & ( Radio.DetectBoardType( ) == SX1272MB2XAS ) ), "\n\r > Board Type: SX1272MB2xAS < \n\r" );
 
     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" );
+    debug_if_2( LORA_FHSS_ENABLED, "\n\n\r             > LORA FHSS Mode < \n\n\r" );
+    debug_if_2( !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,7 +140,7 @@
 
 #elif USE_MODEM_FSK == 1
 
-    debug("\n\n\r              > FSK Mode < \n\n\r" );
+    debug_2("\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,
@@ -157,7 +157,7 @@
 
 #endif
 
-    debug_if( DEBUG_MESSAGE, "Starting Ping-Pong loop\r\n" );
+    debug_if_2( DEBUG_MESSAGE, "Starting Ping-Pong loop\r\n" );
 
     led = 0;
 
@@ -175,7 +175,7 @@
                     if( strncmp( ( const char* )Buffer, ( const char* )PongMsg, 4 ) == 0 )
                     {
                         led = !led;
-                        debug( "...Pong\r\n" );
+                        debug_2( "...Pong\r\n" );
                         // Send the next PING frame
                         strcpy( ( char* )Buffer, ( char* )PingMsg );
                         // We fill the buffer with numbers for the payload
@@ -188,7 +188,7 @@
                     }
                     else if( strncmp( ( const char* )Buffer, ( const char* )PingMsg, 4 ) == 0 )
                     { // A master already exists then become a slave
-                        debug( "...Ping\r\n" );
+                        debug_2( "...Ping\r\n" );
                         led = !led;
                         isMaster = false;
                         // Send the next PONG frame
@@ -215,7 +215,7 @@
                     if( strncmp( ( const char* )Buffer, ( const char* )PingMsg, 4 ) == 0 )
                     {
                         led = !led;
-                        debug( "...Ping\r\n" );
+                        debug_2( "...Ping\r\n" );
                         // Send the reply to the PING string
                         strcpy( ( char* )Buffer, ( char* )PongMsg );
                         // We fill the buffer with numbers for the payload
@@ -309,7 +309,7 @@
 {
     Radio.Sleep( );
     State = TX;
-    debug_if( DEBUG_MESSAGE, "> OnTxDone\n\r" );
+    debug_if_2( DEBUG_MESSAGE, "> OnTxDone\n\r" );
 }
 
 void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
@@ -320,14 +320,14 @@
     RssiValue = rssi;
     SnrValue = snr;
     State = RX;
-    debug_if( DEBUG_MESSAGE, "> OnRxDone\n\r" );
+    debug_if_2( DEBUG_MESSAGE, "> OnRxDone\n\r" );
 }
 
 void OnTxTimeout( void )
 {
     Radio.Sleep( );
     State = TX_TIMEOUT;
-    debug_if( DEBUG_MESSAGE, "> OnTxTimeout\n\r" );
+    debug_if_2( DEBUG_MESSAGE, "> OnTxTimeout\n\r" );
 }
 
 void OnRxTimeout( void )
@@ -335,12 +335,12 @@
     Radio.Sleep( );
     Buffer[BufferSize] = 0;
     State = RX_TIMEOUT;
-    debug_if( DEBUG_MESSAGE, "> OnRxTimeout\n\r" );
+    debug_if_2( DEBUG_MESSAGE, "> OnRxTimeout\n\r" );
 }
 
 void OnRxError( void )
 {
     Radio.Sleep( );
     State = RX_ERROR;
-    debug_if( DEBUG_MESSAGE, "> OnRxError\n\r" );
+    debug_if_2( DEBUG_MESSAGE, "> OnRxError\n\r" );
 }