General testings

Dependencies:   mbed

Fork of BEACON_CODE_NEW by Mohamed Azad

Files at this revision

API Documentation at this revision

Comitter:
shekhar
Date:
Mon Oct 05 11:51:33 2015 +0000
Parent:
9:aeeb97970484
Child:
11:b341766c14b5
Commit message:
removed skip_iterations and low_power_counter

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sun Oct 04 22:48:48 2015 +0000
+++ b/main.cpp	Mon Oct 05 11:51:33 2015 +0000
@@ -5,7 +5,6 @@
 SPI spi(D11, D12, D13);              // mosi, miso, sclk
 DigitalOut cs(D10);                //slave select or chip select
 
-bool skip_Iteration = false;         //initialization for skip_Iteration flag  //skip_Iteration = false if program is running; skip_Iteration = true if program needs to skip one iteration
 Timer t;
 
 void P_BCN_INIT()
@@ -26,7 +25,7 @@
     
     if(BCN_FEN == 1)
     {
-        if(BCN_TX_EN == 1 && skip_Iteration == false)
+        if(BCN_TX_EN == 1)
         {
             //Measure and store BCN temperature in BCN_TS_BUFFER
             BCN_TS_BUFFER = ((check_Temperature())*0.5) - 64;
@@ -36,18 +35,13 @@
             {
                 Set_BCN_TX_STATUS(BCN_TX_STANDBY);
                 BCN_TX_MAIN_STATUS = 0;
-                skip_Iteration = true;
+                
                 // break;
             }
-            else if(BCN_TX_STANDBY != 1 && skip_Iteration == false)
+            else
             {
                 //pc.printf("in BCN_TX_STANDBY != 1\r\n");
-                if(check_POWER_LEVEL() > 0 && skip_Iteration == false)
-                {  
-                    LOW_POWER_COUNTER = 0; //this is used for cases where earlier the power is low and counter was incrementing 
                 
-                    //Power level is measured using SoC(State of Charge)  //PowerLevel>0
-                    //pc.printf("Entering SHORT_BCN_TX\r\n");
                     //t.start();
                     //int begin = t.read_us();
                     SHORT_BCN_TX();
@@ -56,70 +50,36 @@
                     //pc.printf("The time required for short and long is %d microseconds\r\n", end-begin);
                     pc.printf("Short and Long packets sent\r\n");
                     //include LONG_BCN_TX also
-                    if(Check_ACK_RECEIVED() == 1 && skip_Iteration == false)
+                    if(Check_ACK_RECEIVED() == 1)
                     {
                         Set_BCN_TX_STATUS(BCN_TX_SUCCESS);
                         BCN_TX_MAIN_STATUS = 0;
                         // break;
-                        skip_Iteration = true;
+                        
                     }
-                    else if(Check_ACK_RECEIVED() == 0 && skip_Iteration == false)
+                    else
                     {
                         Set_BCN_TX_STATUS(BCN_TX_FAILURE);
                         BCN_TX_MAIN_STATUS = 0;
                         // break;
-                        skip_Iteration = true;
+                        
                     }
-                }
-                else if(check_POWER_LEVEL() == 0 && skip_Iteration == false)
-                {
-                    INC_BCN_LOW_POWER_COUNTER();
-                    //in low power mode: we start the counter
-                    if(LOW_POWER_COUNTER == 3 && skip_Iteration == false)
-                    {
-                        SHORT_BCN_TX();
-                        LONG_BCN_TX();
-                        //include LONG_BCN_TX also
-                        if(Check_ACK_RECEIVED() == 1 && skip_Iteration == false)
-                        {
-                            Set_BCN_TX_STATUS(BCN_TX_SUCCESS);
-                            BCN_TX_MAIN_STATUS = 0;
-                            // break;    
-                            skip_Iteration = true;
-                        }
-                        else if(Check_ACK_RECEIVED() != 1 && skip_Iteration == false)
-                        {
-                            Set_BCN_TX_STATUS(BCN_TX_FAILURE);
-                            BCN_TX_MAIN_STATUS = 0;
-                            // break;
-                            skip_Iteration = true;
-                        }
-                    }
-                    else if(LOW_POWER_COUNTER != 3 && skip_Iteration == false)
-                    {
-                        BCN_TX_MAIN_STATUS = 0;
-                        // break;
-                        skip_Iteration = true;
-                    }
-                }
-            }
+             }
         }
-        else if(BCN_TX_EN != 1 && skip_Iteration == false)
+        else
         {
             Set_BCN_TX_STATUS(BCN_TX_DISABLED);
             BCN_TX_MAIN_STATUS = 0;
             // break;
-            skip_Iteration = true;
+            
         }
     }
     else
     {
         Set_BCN_TX_STATUS(BCN_RF_SILENCE);  //Window of RF Silence: None of the Txs should be on.
         BCN_TX_MAIN_STATUS = 0;
-        skip_Iteration = true;
         // break;
     }
-    skip_Iteration = false;
 }
 
 void Set_BCN_TX_STATUS(uint8_t STATUS)