arm studio build

Dependencies:   libxDot-mbed5

Revision:
12:7944e4dbe853
Parent:
11:77fe4f18a81b
Child:
13:1f3a8d0be511
--- a/src/main.cpp	Thu Oct 18 17:17:26 2018 +0000
+++ b/src/main.cpp	Thu Jan 17 14:21:33 2019 +0000
@@ -1,4 +1,4 @@
-#include "mbed.h"
+ #include "mbed.h"
 #include "global.h"
 #include "commI2C.h"
 #include "dot_util.h"
@@ -29,7 +29,7 @@
 //api_level: proc code will not run if api level (last two bytess) greater than what it expects
 //=======================================================================================================
 uint8_t api_level[4] = { 0x00, 0x00, 0x00, 0x03 };  //api-level, determines if xdot code works with proc code
-uint8_t ver_level[4] = { 0x00, 0x00, 0x00, 0x08 };  //updated for every code check-in
+uint8_t ver_level[4] = { 0x00, 0x00, 0x00, 0x09 };  //updated for every code check-in
 
 //=======================================================================================================
 //configuring mbed pinsa; https://docs.mbed.com/docs/mbed-os-api-reference/en/latest/APIs/io/DigitalInOut/
@@ -41,11 +41,7 @@
 //=======================================================================================================
 static std::string network_name = "asdfqwer";  //not used
 static std::string network_passphrase = "zxcvasdf"; //not used
-/*
-uint8_t network_id[] = { 0x90, 0xF1, 0x47, 0x90, 0x6C, 0x48, 0x1D, 0x29 };   //static id not used anymore but don't comment out                                
-//OTAA keys
-uint8_t network_key[] = { 0x0F, 0xF9, 0xA2, 0x90, 0x2E, 0xAA, 0x6B, 0x8C, 0x6A, 0x4E, 0xFD, 0x67, 0xF9, 0xA6, 0xF3, 0xD3 };   //appkey                              
-*/
+
 
 #ifdef MT_PRIVATE_NETWORK
 static uint8_t frequency_sub_band = 4; 
@@ -140,7 +136,7 @@
 // in OTA and AUTO_OTA join modes, the credentials can be passed to the library as a name and passphrase or an ID and KEY
 // only one method or the other should be used!
     if (public_network){
-        update_ota_config_id_key(nvmData.network_id,nvmData.network_key, frequency_sub_band, public_network, ack);
+        update_ota_config_id_key(nvmData.key_AppEUI,nvmData.key_AppKey, frequency_sub_band, public_network, ack);
         logInfo("--------------  network configured for public access -----------------------------");
     }    
     else{
@@ -160,8 +156,7 @@
 //=================================================================================================
 int main() {
     uint8_t i;
-    RadioEvent events;
-    
+    RadioEvent events;  //class to return info on rx pkts    
     mDotEvent  mdotevent;   //used to get ping info????
     plan = new lora::ChannelPlan_US915();
 #ifdef GPIO_ENABLE   
@@ -322,8 +317,7 @@
                             bRxDone = false;              //true if callback function RxDone() triggered
                             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
+ //send packet -> return code indicates results, send return code back to proc Dec14,2017
                             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)
@@ -340,7 +334,8 @@
                                     pAck->bAckdata = 1;                                          
                                     upstream_packet.clear();    
                                     upstream_packet = events.get_downstream_packet();
-                                    pAck->rxLen = upstream_packet.size();     
+                                    pAck->rxLen = upstream_packet.size();   
+                                    pAck->appPort = events.port;  
                                     if (pAck->rxLen > I2C_MAX_ACK_DATA){
                                         if(verbose)pc.printf("\r\n got ack with pkt data too large.. rejected\r\n");
                                         break;  
@@ -442,7 +437,7 @@
                         if(verbose)pc.printf("\n\r eui data length: %d",peui->dataLen);                                                                                                                                              
                         break;    
                     case XDOT_CMD_NVM:
-                        if(verbose)pc.printf("\n\r proc cmd: NVM");                                                
+                        if(verbose)pc.printf("\n\r proc cmd: NVM OTAA");                                                
                         pkt_setnvmup  *pUpNvm = (pkt_setnvmup*)&buf_rcv[0];                
                         pkt_setnvmdwn *pDwnNvm= (pkt_setnvmdwn*)&buf_xmt[0];                                                 
                         pDwnNvm->ack = I2C_ACK_PROC;
@@ -455,7 +450,23 @@
                         if (nvmRead(&pDwnNvm->nvmData))
                             pDwnNvm->bChkSumOK = 1;    
                         printNmvData(&pDwnNvm->nvmData);    
-                        break;                            
+                        break;                                                   
+                    case XDOT_CMD_NVM_ABP:
+                        if(verbose)pc.printf("\n\r proc cmd: NVM ABP");                                                
+                        pkt_setnvmABPup  *pUpNvmABP = (pkt_setnvmABPup*)&buf_rcv[0];                
+                        pkt_setnvmABPdwn *pDwnNvmABP= (pkt_setnvmABPdwn*)&buf_xmt[0];                                                 
+                        pDwnNvmABP->ack = I2C_ACK_PROC;
+                        pDwnNvmABP->cmd = XDOT_CMD_NVM_ABP;
+                        pDwnNvmABP->dataLen = sizeof(nvm)-2;
+                        if (pUpNvmABP->nvm_option == XDOT_NVM_SET) nvmWriteABP(&pUpNvmABP->nvmData);
+                                                                    
+                        pDwnNvmABP->bChkSumOK = 0;        
+                        if (nvmReadABP(&pDwnNvmABP->nvmData))
+                            pDwnNvmABP->bChkSumOK = 1;    
+                        printNvmABPData(&pDwnNvmABP->nvmData);    
+                                            
+                        break;   
+                        
                     case XDOT_CMD_SET_NTWKSESS:  //read or write network seesion to xdot flash
                         bool bWriteSession = (bool)buf_rcv[1];
                         if (bWriteSession){