Compression code changed and RLY_TMTC pointers managed

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Revision:
262:752c8689944a
Parent:
12:ffdb29353058
Child:
264:f7d8f9f361e3
--- a/COM_POWER_OFF_TX.h	Thu Jul 14 13:07:30 2016 +0000
+++ b/COM_POWER_OFF_TX.h	Thu Jul 14 17:57:05 2016 +0000
@@ -1,15 +1,97 @@
+#define RESET_CDMS_TC {\
+    Base_tc *RESET_tc = new Short_tc;\
+    RESET_tc->next_TC = NULL;\
+    PUTshort_or_long(RESET_tc,SHORT_TC_CODE);\
+    PUTcrc_pass(RESET_tc,0x1);\
+    PUTexec_status(RESET_tc,0);\
+    RESET_tc->TC_string[0] = 0x01;\
+    RESET_tc->TC_string[1] = 0x81;\
+    RESET_tc->TC_string[2] = 0x81;\
+    RESET_tc->TC_string[3] = 0x38;\
+    RESET_tc->TC_string[4] = 0;\
+    RESET_tc->TC_string[5] = 0;\
+    RESET_tc->TC_string[6] = 0;\
+    RESET_tc->TC_string[7] = 0;\
+    RESET_tc->TC_string[8] = 0;\
+    uint16_t crc16 = crc16_gen(RESET_tc->TC_string, 9);\
+    RESET_tc->TC_string[9]  = (crc16 & 0xFF00)>>8;\
+    RESET_tc->TC_string[10] = (crc16 & 0x00FF);\
+    Base_tm *tm_ptr = NULL;\
+    tm_ptr =  FCTN_CDMS_RLY_TMTC(RESET_tc);\
+    delete RESET_tc;\
+    /*DELETE THE TM AFTER USE*/\
+    Base_tm *del_tm = tm_ptr;\
+    while( del_tm != NULL ){\
+        Base_tm *temp = del_tm->next_TM;\
+        delete del_tm;\
+        del_tm = temp;\
+    }\
+}
+
+#define resume_bcn {\
+    Base_tc *beacon_tc = new Long_tc;\
+    beacon_tc->next_TC = NULL;\
+    PUTshort_or_long(beacon_tc,LONG_TC_CODE);\
+    PUTcrc_pass(beacon_tc,0x1);\
+    PUTexec_status(beacon_tc,0);\
+    beacon_tc->TC_string[0] = 0x01;\
+    beacon_tc->TC_string[1] = BCN_APID_SOURCE;\
+    beacon_tc->TC_string[2] = BCN_SERVICE;\
+    beacon_tc->TC_string[3] = 0xE2;\
+    beacon_tc->TC_string[4] = 0x00;\
+    beacon_tc->TC_string[5] = 0;\
+    beacon_tc->TC_string[6] = 0;\
+    beacon_tc->TC_string[7] = 0;\
+    beacon_tc->TC_string[8] = 0;\
+    uint16_t crc16 = crc16_gen(beacon_tc->TC_string, 9);\
+    beacon_tc->TC_string[9]  = (crc16 & 0xFF00)>>8;\
+    beacon_tc->TC_string[10] = (crc16 & 0x00FF);\
+    for(int i = 11; i < 135; i++){\
+        beacon_tc->TC_string[i] = 0;\
+    }\
+    Base_tm *tm_ptr = NULL;\
+    tm_ptr =  FCTN_CDMS_RLY_TMTC(beacon_tc);\
+    delete beacon_tc;\
+    /*DELETE THE TM AFTER USE*/\
+    Base_tm *del_tm = tm_ptr;\
+    int overCount = 0;\
+    while( del_tm != NULL ){\
+        if( (overCount < TM_OVERFLOW_CONSTANT) ){\
+            Base_tm *temp = del_tm->next_TM;\
+            delete del_tm;\
+            del_tm = temp;\
+            ++overCount;\
+        }\
+        else{\
+            RESET_CDMS;\
+            break;\
+        }\
+    }\
+}
+
 #define COM_POWER_OFF_TX {\
     /*gPC.puts("Inside COM_POWER_OFF_TX\r\n");*/\
-    /*PENDING: POWER OFF TRANSMITTER*/\
+    COM_TX_CNTRL = 0;\
     RX1M.attach(&rx_read, Serial::RxIrq);\
     gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
-    /*PENDING: SWITCH RF RELAY TO BEACON*/\
-    /*PENDING: RF_SW_STATUS = RF_BCN*/\
-    /*PENDING: POWER ON BAE*/\
-    /*PENDING: SET BAE SW_EN_STATUS*/\
-    /*PENDING: RESUME BEACON*/\
+    RF_SW_CNTRL_BCN = 1;\
+    Thread::wait(25);\
+    RF_SW_CNTRL_BCN = 0;\
+    gFLAGS = gFLAGS | RF_SW_STATUS_FLAG;\
+    if( gFLAGS & COM_AUTO_POWER_OFF_BAE_FLAG ){\
+        SW_ON_BAE;\
+        gFLAGS & (~COM_AUTO_POWER_OFF_BAE_FLAG);\
+        resume_bcn;\
+    }\
+    else{\
+        if( gFLAGS & BAE_SW_EN_FLAG ){\
+            resume_bcn;\
+        }\
+    }\
     gFLAGS = gFLAGS & (~COM_PA_HOT_FLAG);\
+    gFLAGS = gFLAGS & (~COM_PA_OC_FLAG);\
     gCOM_PA_COOLING_TIMEOUT.detach();\
     gFLAGS = gFLAGS & (~COM_TX_FLAG);\
-    /*gPC.puts("ompleted com_power_off tx\r\n");*/\
+    gFLAGS = gFLAGS & (~COM_SESSION_TIMEOUT_FLAG);\
+    /*gPC.puts("completed com_power_off tx\r\n");*/\
 }
\ No newline at end of file