Implemented LED Indicator Patterns

Dependencies:   mbed

Revision:
18:0a4de80c02a6
Parent:
17:23caa53e6ec1
Child:
19:6f88d1cabaca
diff -r 23caa53e6ec1 -r 0a4de80c02a6 app/main.cpp
--- a/app/main.cpp	Tue Jan 22 17:33:29 2019 +0000
+++ b/app/main.cpp	Wed Jan 23 19:23:44 2019 +0000
@@ -139,7 +139,7 @@
 /*!
  * SOME APPLICATION PARAMETERS
  */
-
+ 
 DigitalOut myled(D7);
 
 DigitalOut relayPin(D6);
@@ -450,11 +450,11 @@
         mcpsReq.Req.Unconfirmed.Datarate = LORAWAN_DEFAULT_DATARATE;
 
         LoRaMacUplinkStatus.Acked = false;
-        LoRaMacUplinkStatus.Port = 42;
+        LoRaMacUplinkStatus.Port = 0;
         LoRaMacUplinkStatus.Buffer = NULL;
         LoRaMacUplinkStatus.BufferSize = 0;
         SerialDisplayUpdateFrameType( false );
-        SerialDisplayPrintDebugLine( LoRaMacQueryTxPossible( AppDataSize, &txInfo ) );
+        SerialDisplayPrintDebugStatus( LoRaMacQueryTxPossible( AppDataSize, &txInfo ) );
         
     }
     else
@@ -486,6 +486,10 @@
 
     if( LoRaMacMcpsRequest( &mcpsReq ) == LORAMAC_STATUS_OK )
     {
+        if( LoRaMacQueryTxPossible( AppDataSize, &txInfo ) != LORAMAC_STATUS_OK )
+        {
+            return true;
+        }
         return false;
     }
     return true;
@@ -1208,7 +1212,23 @@
                     // Schedule next packet transmission
                     TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( -APP_TX_DUTYCYCLE_RND, APP_TX_DUTYCYCLE_RND );
                 }
-                DeviceState = DEVICE_STATE_CYCLE;
+                
+                if ( NextTx == true ) 
+                {
+                    DeviceState = DEVICE_STATE_SLEEP;
+
+                    // Schedule next packet transmission
+                    TimerSetValue( &TxNextPacketTimer, TxDutyCycleTime );
+                    TimerStart( &TxNextPacketTimer );
+                    
+                    char my_str[17] = "Scheduled Resend";
+                    SerialDisplayPrintDebugLine( my_str, 17 );
+                }
+                else
+                {
+                    DeviceState = DEVICE_STATE_CYCLE;
+                }
+                
                 break;
             }
             case DEVICE_STATE_CYCLE: