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.
Fork of SX1272PingPong by
Diff: main.cpp
- Revision:
- 17:c44bd9aea979
- Parent:
- 15:dc867bef95d9
- Child:
- 18:79e1a9635c6d
--- a/main.cpp Mon Mar 13 09:56:13 2017 +0000
+++ b/main.cpp Mon Mar 13 10:58:11 2017 +0000
@@ -33,23 +33,6 @@
DigitalOut led(LED1);
-/*
- * Global variables declarations
- */
-typedef enum {
- LOWPOWER = 0,
- IDLE,
-
- RX,
- RX_TIMEOUT,
- RX_ERROR,
-
- CAD,
- CAD_DONE
-} AppStates_t;
-
-volatile AppStates_t State = LOWPOWER;
-
/*!
* Radio events function pointer
*/
@@ -68,9 +51,7 @@
int main()
{
- uint8_t i;
-
- debug( "\n\n\r iGreenhouse Application \n\n\r" );
+ debug( "\n\n\r iGreenhouse Application - Receiver \n\n\r" );
// Initialize Radio driver
RadioEvents.RxDone = OnRxDone;
@@ -106,34 +87,9 @@
Radio.Rx( RX_TIMEOUT_VALUE );
while( 1 ) {
- switch( State ) {
- case RX:
- if( BufferSize > 0 ) {
- debug("\r\n========\r\nNew Packet\r\n========\r\n");
- debug("%s \r\n", Buffer);
- /*if( strncmp( ( const char* )Buffer, ( const char* )PingMsg, 4 ) == 0 ) {
- led = !led;
- debug( "...Ping\r\n" );
- } else { // valid reception but not a PING as expected, let start again
- Radio.Rx( RX_TIMEOUT_VALUE );
- }*/
- }
- State = LOWPOWER;
- break;
- case RX_TIMEOUT:
- Radio.Rx( RX_TIMEOUT_VALUE );
- State = LOWPOWER;
- break;
- case RX_ERROR:
- // We have received a Packet with a CRC error
- State = LOWPOWER;
- break;
- case LOWPOWER:
- break;
- default:
- State = LOWPOWER;
- break;
- }
+ debug("\r\n========\r\nNew Packet\r\n========\r\n");
+ debug("%s \r\n", Buffer);
+ wait(3);
}
}
@@ -144,7 +100,6 @@
memcpy( Buffer, payload, BufferSize );
RssiValue = rssi;
SnrValue = snr;
- State = RX;
debug_if( DEBUG_MESSAGE, "> OnRxDone\n\r" );
}
@@ -152,14 +107,12 @@
{
Radio.Sleep( );
Buffer[ BufferSize ] = 0;
- State = RX_TIMEOUT;
debug_if( DEBUG_MESSAGE, "> OnRxTimeout\n\r" );
}
void OnRxError( void )
{
Radio.Sleep( );
- State = RX_ERROR;
debug_if( DEBUG_MESSAGE, "> OnRxError\n\r" );
}
