Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SX1276GenericLib USBDevice
Fork of NonPingPong_PICO_LoRa_LP1 by
Diff: SX1276GenericPingPong/GenericPingPong2.cpp
- Revision:
- 8:5ff74d7381dc
- Parent:
- 7:6264bc5b6421
--- a/SX1276GenericPingPong/GenericPingPong2.cpp Fri Oct 16 06:50:04 2020 +0000
+++ b/SX1276GenericPingPong/GenericPingPong2.cpp Fri Oct 16 23:26:04 2020 +0000
@@ -315,135 +315,135 @@
/****************************************************************************************************************************************
*
****************************************************************************************************************************************/
-int SX1276PingPong(void)
-{
-#if MASTER == 1 // Master Device: Bluetooth Gateway
- bool isMaster = true;
-#elif SLAVE == 1 // Slave Device: Robot
- bool isMaster = false;
-#endif
-
- switch( State )
- {
- case RX:
-// *led3 = 0; // uncommented
- if( isMaster == true ) // Master Device received payload from Slave
- {
- if( BufferSizeRx > 0 )
- {
- /* This checks if the ID of the received transaction is matching that of
- * the slave device's ID. This is defined in the GenericPingPong.h
- */
- if( memcmp(&BufferRx[rx_idx_signature], PongMsg, sizeof(PongMsg)) == 0 )
- {
-// *led = !*led;
-// *led = 0; // changed to 0
- if (DEBUG_MESSAGE)
- ad->printf( "...Pong\r\n" );
- wait_ms( 10 );
- Radio->Send( BufferTx, BufferSizeTx );
- } // memcmp != 0
- else // valid reception but not a PONG message
- { // Set device as master and start again
- isMaster = true; // new update
- Radio->Rx( RX_TIMEOUT_VALUE );
- } // end of if memcmp
- } // end of if BufferSizeRx > 0
- } // end of isMaster == true
- else // Slave Device received payload from Master
- {
- if( BufferSizeRx > 0 )
- {
- if( memcmp(BufferRx, PingMsg, sizeof(PingMsg)) == 0 )
- {
-// *led = !*led;
-// *led = 0 //changed to 0
- if (DEBUG_MESSAGE)
- ad->printf( "...Ping\r\n" );
- wait_ms( 10 );
- Radio->Send( BufferTx, BufferSizeTx );
- }
- else // valid reception but not a PING as expected
- { // Set device as slave and start again
- isMaster = false; // new update
- Radio->Rx( RX_TIMEOUT_VALUE );
- }
- } // end of if BufferSizeRx > 0
- } // end of if (isMaster == True), end of checking devices
-
- State = LOWPOWER; // back to LOWPOWER State
-
- break;
- case TX:
-// *led3 = 0; // change to 0
- if( isMaster == true ) // Master Device
- {
- if (DEBUG_MESSAGE)
- ad->printf("Ping...\r\n" );
- }
- else // Slave Device
- {
- if (DEBUG_MESSAGE)
- ad->printf("Pong...\r\n" );
- }
- Radio->Rx( RX_TIMEOUT_VALUE );
- State = LOWPOWER; // back to LOWPOWER State
- break;
- case RX_TIMEOUT:
- if( isMaster == true ) // Master Device
- {
- wait_ms( 10 );
- Radio->Send( BufferTx, BufferSizeTx );
- }
- else // Slave Device
- {
- Radio->Rx( RX_TIMEOUT_VALUE );
- }
- State = LOWPOWER; // back to LOWPOWER State
- break;
- case RX_ERROR:
- // We have received a Packet with a CRC error, send reply as if packet was correct
- if( isMaster == true ) // Master Device
- {
- // Send the next PING frame
-// memcpy(BufferTx, PingMsg, sizeof(PingMsg));
-/*
- for( i = 4; i < BufferSizeTx; i++ )
- {
- BufferTx[i] = i - 4;
- }
-*/
-// fillPayloadWithGlobalBufs(BufferTx);
- wait_ms( 10 );
- Radio->Send( BufferTx, BufferSizeTx );
- }
- else // Slave Device
- {
- // Send the next PONG frame
-// memcpy(BufferTx, PongMsg, sizeof(PongMsg));
-/*
- for( i = sizeof(PongMsg); i < BufferSizeTx; i++ )
- {
- BufferTx[i] = i - sizeof(PongMsg);
- }
-*/
- wait_ms( 10 );
- Radio->Send( BufferTx, BufferSizeTx );
- }
- State = LOWPOWER; // Back to Low Power State
- break;
- case TX_TIMEOUT:
- Radio->Rx( RX_TIMEOUT_VALUE );
- State = LOWPOWER;
- break;
- case LOWPOWER:
- sleep();
- break;
- default:
- State = LOWPOWER;
- break;
- }
-}
+//int SX1276PingPong(void)
+//{
+//#if MASTER == 1 // Master Device: Bluetooth Gateway
+// bool isMaster = true;
+//#elif SLAVE == 1 // Slave Device: Robot
+// bool isMaster = false;
+//#endif
+//
+// switch( State )
+// {
+// case RX:
+//// *led3 = 0; // uncommented
+// if( isMaster == true ) // Master Device received payload from Slave
+// {
+// if( BufferSizeRx > 0 )
+// {
+// /* This checks if the ID of the received transaction is matching that of
+// * the slave device's ID. This is defined in the GenericPingPong.h
+// */
+// if( memcmp(&BufferRx[rx_idx_signature], PongMsg, sizeof(PongMsg)) == 0 )
+// {
+//// *led = !*led;
+//// *led = 0; // changed to 0
+// if (DEBUG_MESSAGE)
+// ad->printf( "...Pong\r\n" );
+// wait_ms( 10 );
+// Radio->Send( BufferTx, BufferSizeTx );
+// } // memcmp != 0
+// else // valid reception but not a PONG message
+// { // Set device as master and start again
+// isMaster = true; // new update
+// Radio->Rx( RX_TIMEOUT_VALUE );
+// } // end of if memcmp
+// } // end of if BufferSizeRx > 0
+// } // end of isMaster == true
+// else // Slave Device received payload from Master
+// {
+// if( BufferSizeRx > 0 )
+// {
+// if( memcmp(BufferRx, PingMsg, sizeof(PingMsg)) == 0 )
+// {
+//// *led = !*led;
+//// *led = 0 //changed to 0
+// if (DEBUG_MESSAGE)
+// ad->printf( "...Ping\r\n" );
+// wait_ms( 10 );
+// Radio->Send( BufferTx, BufferSizeTx );
+// }
+// else // valid reception but not a PING as expected
+// { // Set device as slave and start again
+// isMaster = false; // new update
+// Radio->Rx( RX_TIMEOUT_VALUE );
+// }
+// } // end of if BufferSizeRx > 0
+// } // end of if (isMaster == True), end of checking devices
+//
+// State = LOWPOWER; // back to LOWPOWER State
+//
+// break;
+// case TX:
+//// *led3 = 0; // change to 0
+// if( isMaster == true ) // Master Device
+// {
+// if (DEBUG_MESSAGE)
+// ad->printf("Ping...\r\n" );
+// }
+// else // Slave Device
+// {
+// if (DEBUG_MESSAGE)
+// ad->printf("Pong...\r\n" );
+// }
+// Radio->Rx( RX_TIMEOUT_VALUE );
+// State = LOWPOWER; // back to LOWPOWER State
+// break;
+// case RX_TIMEOUT:
+// if( isMaster == true ) // Master Device
+// {
+// wait_ms( 10 );
+// Radio->Send( BufferTx, BufferSizeTx );
+// }
+// else // Slave Device
+// {
+// Radio->Rx( RX_TIMEOUT_VALUE );
+// }
+// State = LOWPOWER; // back to LOWPOWER State
+// break;
+// case RX_ERROR:
+// // We have received a Packet with a CRC error, send reply as if packet was correct
+// if( isMaster == true ) // Master Device
+// {
+// // Send the next PING frame
+//// memcpy(BufferTx, PingMsg, sizeof(PingMsg));
+///*
+// for( i = 4; i < BufferSizeTx; i++ )
+// {
+// BufferTx[i] = i - 4;
+// }
+//*/
+//// fillPayloadWithGlobalBufs(BufferTx);
+// wait_ms( 10 );
+// Radio->Send( BufferTx, BufferSizeTx );
+// }
+// else // Slave Device
+// {
+// // Send the next PONG frame
+//// memcpy(BufferTx, PongMsg, sizeof(PongMsg));
+///*
+// for( i = sizeof(PongMsg); i < BufferSizeTx; i++ )
+// {
+// BufferTx[i] = i - sizeof(PongMsg);
+// }
+//*/
+// wait_ms( 10 );
+// Radio->Send( BufferTx, BufferSizeTx );
+// }
+// State = LOWPOWER; // Back to Low Power State
+// break;
+// case TX_TIMEOUT:
+// Radio->Rx( RX_TIMEOUT_VALUE );
+// State = LOWPOWER;
+// break;
+// case LOWPOWER:
+// sleep();
+// break;
+// default:
+// State = LOWPOWER;
+// break;
+// }
+//}
int TimeOnAirSend(void) {
