1

Dependencies:   X_NUCLEO_IKS01A1 LoRaWAN-lib SX1276Lib mbed

Revision:
7:730764a067dc
Parent:
6:711a4e008afa
--- a/app/LoRaEventProc.cpp	Tue Nov 28 08:20:09 2017 +0000
+++ b/app/LoRaEventProc.cpp	Wed Dec 06 07:35:47 2017 +0000
@@ -46,17 +46,24 @@
             // Point the pointer to position index of Tx Buffer
             LoRaApp.ApplicationPtrPos( ptrIndex );
 
-            if( DutyCycleIndx == 0 )
-            {
-                tmp = 0xAA;     
-            }
-            else if( DutyCycleIndx == 1 )
+            if( IsDeviceReady == true )
             {
-                tmp = 0xBB;
+                if( DutyCycleIndx == 0 )
+                {
+                    tmp = 0xAA;     
+                }
+                else if( DutyCycleIndx == 1 )
+                {
+                    tmp = 0xBB;
+                }
+                else if( DutyCycleIndx > 1 )
+                {
+                    tmp = 0xCC;
+                }
             }
-            else if( DutyCycleIndx > 1 )
+            else
             {
-                tmp = 0xCC;
+                tmp = 0xFF;
             }
             tmpLength = 1;
 
@@ -335,32 +342,37 @@
 }
 
 void InitDutyCycleTimer( void )
-{
+{       
     if( DutyCycleIndx == 0 )
     {
-        printf("DutyCyle = A\r\n");
-        AppTxDutyCycle = APP_TX_DUTYCYCLE;
-        AppTxDutyCycleRnd = APP_TX_DUTYCYCLE_RND;       
+        AppTxDutyCycle = APP_TX_DUTYCYCLE_1;
+        AppTxDutyCycleRnd = APP_TX_DUTYCYCLE_RND_1;       
     }
     else if( DutyCycleIndx == 1 )
     {
-        printf("DutyCyle = B\r\n");
-        AppTxDutyCycle = APP_TX_DUTYCYCLE_1;
-        AppTxDutyCycleRnd = APP_TX_DUTYCYCLE_RND_1;     
+        AppTxDutyCycle = APP_TX_DUTYCYCLE_2;
+        AppTxDutyCycleRnd = APP_TX_DUTYCYCLE_RND_2;     
     }
     else if( DutyCycleIndx > 1 )
     {
-        printf("DutyCyle = C\r\n");
-        AppTxDutyCycle = APP_TX_DUTYCYCLE_2;
-        AppTxDutyCycleRnd = APP_TX_DUTYCYCLE_RND_2;     
+        AppTxDutyCycle = APP_TX_DUTYCYCLE_3;
+        AppTxDutyCycleRnd = APP_TX_DUTYCYCLE_RND_3;     
     }
     
-    // Schedule next packet transmission
-    TxDutyCycleTime =  1800000000;
+    // 30 min timer
+    TxDutyCycleTime =  1800 * USEC;
     TimerSetValue( &TxDutyCycleTimer, TxDutyCycleTime );
     TimerStart( &TxDutyCycleTimer );
 }
 
+void InitDelayTimer( void )
+{   
+    // 30 min timer
+    TxDutyCycleTime =  1800 * USEC;
+    TimerSetValue( &TxDelayTimer, TxDutyCycleTime );
+    TimerStart( &TxDelayTimer );
+}
+
 /*!
  * \brief   What to do during JOIN process ? blink/toggle LED etc.
  */