init

Dependencies:   SX1276Lib_modtronix mbed

Fork of SX1276PingPong_inAir by ENEL400

Files at this revision

API Documentation at this revision

Comitter:
Razorfoot
Date:
Wed Sep 14 05:47:41 2016 +0000
Parent:
16:3d22f4dd0311
Commit message:
init;

Changed in this revision

SX1276Lib_inAir.lib Show diff for this revision Revisions of this file
SX1276Lib_modtronix.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 3d22f4dd0311 -r 4fcf3c76cab7 SX1276Lib_inAir.lib
--- a/SX1276Lib_inAir.lib	Mon Jul 11 01:25:28 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/teams/ENEL400/code/SX1276Lib_inAir/#bc0732f29f43
diff -r 3d22f4dd0311 -r 4fcf3c76cab7 SX1276Lib_modtronix.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SX1276Lib_modtronix.lib	Wed Sep 14 05:47:41 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/modtronix/code/SX1276Lib_modtronix/#72381be1b0ce
diff -r 3d22f4dd0311 -r 4fcf3c76cab7 main.cpp
--- a/main.cpp	Mon Jul 11 01:25:28 2016 +0000
+++ b/main.cpp	Wed Sep 14 05:47:41 2016 +0000
@@ -14,11 +14,11 @@
 
 #if USE_MODEM_LORA == 1
 
-    #define LORA_BANDWIDTH                              2         // [0: 125 kHz,
-                                                                  //  1: 250 kHz,
-                                                                  //  2: 500 kHz,
-                                                                  //  3: Reserved]
-    #define LORA_SPREADING_FACTOR                       7         // [SF7..SF12]
+    #define LORA_BANDWIDTH                              9         // [7: 125 kHz, changed from 2 to 9
+                                                                  //  8: 250 kHz,
+                                                                  //  9: 500 kHz,
+                                                                  //  X: Reserved]
+    #define LORA_SPREADING_FACTOR                       12         // [SF7..SF12]
     #define LORA_CODINGRATE                             1         // [1: 4/5,
                                                                   //  2: 4/6,
                                                                   //  3: 4/7,
@@ -29,7 +29,7 @@
     #define LORA_FHSS_ENABLED                           false  
     #define LORA_NB_SYMB_HOP                            4     
     #define LORA_IQ_INVERSION_ON                        false
-    #define LORA_CRC_ENABLED                            true
+    #define LORA_CRC_ENABLED                            true //changed from false to true
     
 #elif USE_MODEM_FSK == 1
 
@@ -57,7 +57,7 @@
 /*
  *  Global variables declarations
  */
-typedef enum
+/*typedef enum
 {
     LOWPOWER = 0,
     IDLE,
@@ -71,19 +71,21 @@
     
     CAD,
     CAD_DONE
-}AppStates_t;
+}AppStates_t;*/
 
-volatile AppStates_t State = LOWPOWER;
+//volatile AppStates_t State = LOWPOWER; //Not using anymore
+volatile enum RadioState State = LOWPOWER;
 
 /*!
  * Radio events function pointer
  */
-static RadioEvents_t RadioEvents;
+//static RadioEvents_t RadioEvents; //Not using anymore
 
 /*
  *  Global variables declarations
  */
-SX1276inAir Radio( NULL );
+SX1276inAir Radio(OnTxDone, OnTxTimeout, OnRxDone, OnRxTimeout, OnRxError, NULL, NULL); //No longer NULL
+//SX1276inAir Radio(NULL);
 
 const uint8_t PingMsg[] = "PING";
 const uint8_t PongMsg[] = "PONG";
@@ -102,12 +104,12 @@
     printf( "\n\n\r     SX1276 Ping Pong Demo Application \n\n\r" );
 
     // Initialize Radio driver
-    RadioEvents.TxDone = OnTxDone;
+    /*RadioEvents.TxDone = OnTxDone;
     RadioEvents.RxDone = OnRxDone;
     RadioEvents.RxError = OnRxError;
     RadioEvents.TxTimeout = OnTxTimeout;
-    RadioEvents.RxTimeout = OnRxTimeout;
-    Radio.Init( &RadioEvents );
+    RadioEvents.RxTimeout = OnRxTimeout; //Moved to the class constructor
+    Radio.Init( &RadioEvents );*/
     
     // verify the connection with the board
     while( Radio.Read( REG_VERSION ) == 0x00  )
@@ -125,7 +127,7 @@
                          LORA_SPREADING_FACTOR, LORA_CODINGRATE,
                          LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
                          LORA_CRC_ENABLED, LORA_FHSS_ENABLED, LORA_NB_SYMB_HOP, 
-                         LORA_IQ_INVERSION_ON, 2000000 );
+                         LORA_IQ_INVERSION_ON, 4000000 ); //changed from 2000000 to 4000000
     
     Radio.SetRxConfig( MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR,
                          LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH,
@@ -160,7 +162,7 @@
     {
         switch( State )
         {
-        case RX:
+        case RX_DONE: //No longer case RX
             if( isMaster == true )
             {
                 if( BufferSize > 0 )
@@ -228,7 +230,7 @@
             }
             State = LOWPOWER;
             break;
-        case TX:    
+        case TX_DONE:    //No longer case TX
             led = !led; 
             if( isMaster == true )  
             {
@@ -301,7 +303,7 @@
 void OnTxDone( void )
 {
     Radio.Sleep( );
-    State = TX;
+    State = TX_DONE; //no longer TX
     printf( "> OnTxDone\n\r" );
 }
 
@@ -312,8 +314,9 @@
     memcpy( Buffer, payload, BufferSize );
     RssiValue = rssi;
     SnrValue = snr;
-    State = RX;
+    State = RX_DONE; //no longer RX
     printf( "> OnRxDone\n\r" );
+    printf("RSSI: %d\r\nSNR: %d\r\n\r\n", RssiValue, SnrValue);
 }
 
 void OnTxTimeout( void )