arm studio build

Dependencies:   libxDot-mbed5

Revision:
15:ed77b752eaa9
Parent:
14:fc836a5a5d2f
Child:
16:5cc10d804d49
--- a/src/main.cpp	Fri Jan 18 18:15:29 2019 +0000
+++ b/src/main.cpp	Sat Jan 19 14:53:54 2019 +0000
@@ -6,16 +6,20 @@
 #include "multicast.h"
 #include "mDot.h"
 #include "RadioEvent.h"
+#include "ChannelPlans.h"
 #include "Lora.h"
 
+bool verbose =  true;
 bool bRxDone = false;              //true if callback function RxDone() triggered
 bool bDownLinkCntrFail = false;    //true if callback function RxDone() triggered and bad downlink frame count
+bool bClassA =  true;              //false => Class C multicast mode
 
 //nvm storage params
 nvm nvmData;
 nvm *pNvmData = &nvmData;
 
-bool verbose =  true;
+
+
 //=======================================================================================================
 // enable GPIO for scope trigger
 //=======================================================================================================
@@ -63,8 +67,8 @@
 int16_t wait_before_sleep_usec =  10000;  
 //=======================================================================================================
 // deepsleep consumes slightly less current than sleep
-// in sleep mode, IO state is maintained, RAM is retained, and application will resume after waking up
-// in deepsleep mode, IOs float, RAM is lost, and application will start from beginning after waking up
+// sleep mode:     IO state is maintained, RAM is retained, and application will resume after waking up
+// deepsleep mode: IOs float, RAM is lost, and application will start from beginning after waking up
 // if deep_sleep == true, device will enter deepsleep mode
 // asb:
 //  no longer use deepsleep since we want to retain state
@@ -159,7 +163,8 @@
     uint8_t i;
     RadioEvent events;  //class to return info on rx pkts    
     mDotEvent  mdotevent;   //used to get ping info????
-    plan = new lora::ChannelPlan_US915();
+    //plan = new lora::ChannelPlan_US915();
+    static lora::ChannelPlan_US915 plan;
 #ifdef GPIO_ENABLE   
     gpio1.output();    
     gpio1 =0;         
@@ -171,11 +176,15 @@
     pc.printf("COMM api_level = <HEX> %x.%x.%x.%x\r\n",api_level[0],api_level[1],api_level[2],api_level[3]);
     pc.printf("COMM version   =       %x.%x.%x.%x\r\n",ver_level[0],ver_level[1],ver_level[2],ver_level[3]);
     pc.printf("**********************************************************\r\n");   
-    assert(plan);
-    dot = mDot::getInstance(plan);
-    assert(dot);  
+    //assert(plan);
+    //dot = mDot::getInstance(plan);
+    dot = mDot::getInstance(&plan); 
+    //assert(dot);  
       
-    dot->setEvents(&events);        
+    //dot->setEvents(&events);        
+
+    
+    
     nvmRead(pNvmData);
 
     if (pNvmData->bLogOutputOn == 0){
@@ -245,8 +254,17 @@
 #ifdef GPIO_ENABLE
                gpio1 =0; 
 #endif
-                wait_us(wait_before_sleep_usec); //wait for i2c to complete data transfer before sleeping
-                sleep_wake_interrupt_only(deep_sleep);   ////sleep until rising edge of wake signal from proc
+                wait_us(wait_before_sleep_usec);         //wait for i2c to complete data transfer before sleeping
+//#ifdef NOTYET
+                if (!bClassA){      
+                    if(verbose)pc.printf("\n\r changed to class C, LISTEN ONLY \r\n");                                  
+                    wait(1800);    // CLASS C MODE LISTEN ONLY !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+                }    
+//#endif                
+                else{
+                    sleep_wake_interrupt_only(deep_sleep);   //sleep until rising edge of wake signal from proc
+                }    
+                
 #ifdef GPIO_ENABLE
               gpio1 =1;  
 #endif
@@ -271,7 +289,6 @@
                         if(pUp->chksum != chksum){
                             if(verbose)pc.printf(" chksum err, aborting xmit");  
                             pAck->bXmitAttempted = 0;                                                  
-                           // pAck->mdot_ret = -2048;  //wbit rtn code?
                            pAck->mdot_ret = XDOT_ERR_I2C_CHKSUM;
                            pAck->chksum_err = 1;
                            break;
@@ -312,7 +329,8 @@
                                if(verbose)pc.printf("\r\n----------- FAILED TO JOIN...GIVING UP\r\n");  // join network if not joined                                                         
                             else {
                                 save_OTAA_session_keys();
-                            }       
+                                plan.SetRx2DatarateIndex(8);  //LORIOT FIX FOR RX2 & OTA !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  ---> doesn't work here????    
+                            }                                   
                         }         
                         if (joined)
                         {          
@@ -322,6 +340,7 @@
                             bDownLinkCntrFail = false;    //true if callback function RxDone() triggered and bad downlink frame count
 
  //send packet -> return code indicates results, send return code back to proc Dec14,2017
+                    plan.SetRx2DatarateIndex(8);  //LORIOT FIX FOR RX2 & OT  --- work here?????
                             pAck->mdot_ret = dot->send(upstream_packet);  //xmit the pkt in blocking mode, return false if no ack     
                             if (verbose)printf("\n\rdata->send() return code: %d\r\n",pAck->mdot_ret);                                     
                             if (pAck->mdot_ret == mDot::MDOT_OK)
@@ -479,15 +498,10 @@
                         pDwnSetClass->cmd = XDOT_CMD_SET_RADIO_CLASS;
                         pDwnSetClass->dataLen = sizeof(class_switch)-2;                        
                         bool bOk = multicast_change_class(&pUpSetClass->classData);
-                        pDwnSetClass->bSwitched = bOk;                                                                                                               
+                        if (bOk && pUpSetClass->classData.bClassC) bClassA = false;                        
+                        pDwnSetClass->bSwitched = bOk;                                                                                                                                       
                         break;   
                        
-
-
-
-
-
-
                         
                     case XDOT_CMD_SET_NTWKSESS:  //read or write network seesion to xdot flash
                         bool bWriteSession = (bool)buf_rcv[1];