LoRa node acquiring analog input and sending to LoRa Server - Working ok

Dependents:   DISCO-L072CZ-LRWAN1_LoRa_node EIoT_LoRa_node_1 EIoT_LoRa_node_2 EIoT_LoRa_node_3

Fork of SX1276GenericLib by Helmut Tschemernjak

Revision:
42:72deced1a4c4
Parent:
38:d9189d958db8
Child:
44:544add59b26d
diff -r 2dbc4afedf61 -r 72deced1a4c4 sx1276/sx1276.cpp
--- a/sx1276/sx1276.cpp	Mon May 08 15:39:42 2017 +0200
+++ b/sx1276/sx1276.cpp	Mon May 08 22:52:31 2017 +0200
@@ -709,8 +709,8 @@
 
 void SX1276::Sleep( void )
 {
-    txTimeoutTimer.detach( );
-    rxTimeoutTimer.detach( );
+    SetTimeout(TXTimeoutTimer, 0);
+    SetTimeout(RXTimeoutTimer, 0);
 
     SetOpMode( RF_OPMODE_SLEEP );
     this->settings.State = RF_IDLE;
@@ -718,8 +718,8 @@
 
 void SX1276::Standby( void )
 {
-    txTimeoutTimer.detach( );
-    rxTimeoutTimer.detach( );
+    SetTimeout(TXTimeoutTimer, 0);
+    SetTimeout(RXTimeoutTimer, 0);
 
     SetOpMode( RF_OPMODE_STANDBY );
     this->settings.State = RF_IDLE;
@@ -864,7 +864,7 @@
     this->settings.State = RF_RX_RUNNING;
     if( timeout != 0 )
     {
-        rxTimeoutTimer.attach_us(callback( this, &SX1276::OnTimeoutIrq ), timeout * 1e3 );
+        SetTimeout(RXTimeoutTimer, timeout * 1e3 );
     }
 
     if( this->settings.Modem == MODEM_FSK )
@@ -873,8 +873,7 @@
 
         if( rxContinuous == false )
         {
-            rxTimeoutSyncWord.attach_us(callback( this, &SX1276::OnTimeoutIrq ),
-                                        this->settings.Fsk.RxSingleTimeout * 1e3 );
+            SetTimeout(RXTimeoutSyncWorldTimer, this->settings.Fsk.RxSingleTimeout * 1e3);
         }
     }
     else
@@ -948,7 +947,7 @@
     }
 
     this->settings.State = RF_TX_RUNNING;
-    txTimeoutTimer.attach_us(callback( this, &SX1276::OnTimeoutIrq ), timeout * 1e3 );
+    SetTimeout(TXTimeoutTimer,  timeout * 1e3);
     SetOpMode( RF_OPMODE_TRANSMITTER );
 }
 
@@ -999,7 +998,7 @@
     Write( REG_DIOMAPPING2, RF_DIOMAPPING2_DIO4_10 | RF_DIOMAPPING2_DIO5_10 );
     
     this->settings.State = RF_TX_RUNNING;
-    txTimeoutTimer.attach_us( mbed::callback( this, &SX1276::OnTimeoutIrq ), timeout );
+    SetTimeout(TXTimeoutTimer, timeout);
     SetOpMode( RF_OPMODE_TRANSMITTER );
 }
 
@@ -1137,13 +1136,12 @@
             {
                 // Continuous mode restart Rx chain
                 Write( REG_RXCONFIG, Read( REG_RXCONFIG ) | RF_RXCONFIG_RESTARTRXWITHOUTPLLLOCK );
-                rxTimeoutSyncWord.attach_us( mbed::callback( this, &SX1276::OnTimeoutIrq ),
-                                            this->settings.Fsk.RxSingleTimeout * 1e3 );
+                SetTimeout(RXTimeoutSyncWorldTimer, this->settings.Fsk.RxSingleTimeout * 1e3);
             }
             else
             {
                 this->settings.State = RF_IDLE;
-                rxTimeoutSyncWord.detach( );
+                SetTimeout(RXTimeoutSyncWorldTimer, 0);
             }
         }
         if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxTimeout != NULL ) )
@@ -1210,19 +1208,18 @@
                                                     RF_IRQFLAGS1_SYNCADDRESSMATCH );
                         Write( REG_IRQFLAGS2, RF_IRQFLAGS2_FIFOOVERRUN );
 
-                        rxTimeoutTimer.detach( );
+                        SetTimeout(RXTimeoutTimer, 0);
 
                         if( this->settings.Fsk.RxContinuous == false )
                         {
-                            rxTimeoutSyncWord.detach( );
+                            SetTimeout(RXTimeoutSyncWorldTimer, 0);
                             this->settings.State = RF_IDLE;
                         }
                         else
                         {
                             // Continuous mode restart Rx chain
                             Write( REG_RXCONFIG, Read( REG_RXCONFIG ) | RF_RXCONFIG_RESTARTRXWITHOUTPLLLOCK );
-                            rxTimeoutSyncWord.attach_us( mbed::callback( this, &SX1276::OnTimeoutIrq ),
-                                                        this->settings.Fsk.RxSingleTimeout * 1e3 );
+                            SetTimeout(RXTimeoutSyncWorldTimer, this->settings.Fsk.RxSingleTimeout * 1e3);
                         }
 
                         if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxError != NULL ) )
@@ -1257,19 +1254,18 @@
                     this->settings.FskPacketHandler.NbBytes += ( this->settings.FskPacketHandler.Size - this->settings.FskPacketHandler.NbBytes );
                 }
 
-                rxTimeoutTimer.detach( );
-
+                SetTimeout(RXTimeoutTimer, 0);
+                    
                 if( this->settings.Fsk.RxContinuous == false )
                 {
                     this->settings.State = RF_IDLE;
-                    rxTimeoutSyncWord.detach( );
+                    SetTimeout(RXTimeoutSyncWorldTimer, 0);
                 }
                 else
                 {
                     // Continuous mode restart Rx chain
                     Write( REG_RXCONFIG, Read( REG_RXCONFIG ) | RF_RXCONFIG_RESTARTRXWITHOUTPLLLOCK );
-                    rxTimeoutSyncWord.attach_us( mbed::callback( this, &SX1276::OnTimeoutIrq ),
-                                                this->settings.Fsk.RxSingleTimeout * 1e3 );
+                    SetTimeout(RXTimeoutSyncWorldTimer, this->settings.Fsk.RxSingleTimeout * 1e3);
 				}
 
                 if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxDone != NULL ) )
@@ -1298,8 +1294,8 @@
                         {
                             this->settings.State = RF_IDLE;
                         }
-                        rxTimeoutTimer.detach( );
-
+                        SetTimeout(RXTimeoutTimer, 0);
+                        
                         if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxError != NULL ) )
                         {
                             this->RadioEvents->RxError( );
@@ -1353,8 +1349,8 @@
                     {
                         this->settings.State = RF_IDLE;
                     }
-                    rxTimeoutTimer.detach( );
-
+                    SetTimeout(RXTimeoutTimer, 0);
+                    
                     if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxDone != NULL ) )
                     {
                         this->RadioEvents->RxDone( rxtxBuffer, this->settings.LoRaPacketHandler.Size, this->settings.LoRaPacketHandler.RssiValue, this->settings.LoRaPacketHandler.SnrValue );
@@ -1366,7 +1362,7 @@
             }
             break;
         case RF_TX_RUNNING:
-			txTimeoutTimer.detach( );
+            SetTimeout(TXTimeoutTimer, 0);
             // TxDone interrupt
             switch( this->settings.Modem )
             {
@@ -1424,8 +1420,8 @@
                 break;
             case MODEM_LORA:
                 // Sync time out
-                rxTimeoutTimer.detach( );
-				// Clear Irq
+                SetTimeout(RXTimeoutTimer, 0);
+                // Clear Irq
 				Write( REG_LR_IRQFLAGS, RFLR_IRQFLAGS_RXTIMEOUT );
 
                 this->settings.State = RF_IDLE;
@@ -1482,8 +1478,8 @@
 
                 if( ( this->settings.FskPacketHandler.PreambleDetected == true ) && ( this->settings.FskPacketHandler.SyncWordDetected == false ) )
                 {
-                    rxTimeoutSyncWord.detach( );
-
+                    SetTimeout(RXTimeoutSyncWorldTimer, 0);
+                    
                     this->settings.FskPacketHandler.SyncWordDetected = true;
 
                     this->settings.FskPacketHandler.RssiValue = -( Read( REG_RSSIVALUE ) >> 1 );