arm studio build

Dependencies:   libxDot-mbed5

Revision:
2:0af50f386eb2
Parent:
1:0d25d9ddbe9f
Child:
4:d87f8dcf40ef
--- a/src/wbit_util.cpp	Sat Aug 04 19:25:02 2018 +0000
+++ b/src/wbit_util.cpp	Sat Aug 04 19:56:33 2018 +0000
@@ -4,20 +4,31 @@
 #include "commI2C.h"
 #include "mbed.h"
 #include "mDot.h"
-
+extern Serial pc;
 uint8_t j_attempts = 0; //return number of attempts it took to join the network
 
 
 //network keys
 //these are used as backup keys in case nvm memory is corrupted and we can't read the keys correctly
 uint8_t network_id[] = { 0x90, 0xF1, 0x47, 0x90, 0x6C, 0x48, 0x1D, 0x29 };   //static id not used anymore but don't comment out                                
-uint8_t network_key[] = { 0x0F, 0xF9, 0xA2, 0x90, 0x2E, 0xAA, 0x6B, 0x8C, 0x6A, 0x4E, 0xFD, 0x67, 0xF9, 0xA6, 0xF3, 0xD3 };   //OTAA appkey                              
+uint8_t network_key[] = { 0x0F, 0xF9, 0xA2, 0x90, 0x2E, 0xAA, 0x6B, 0x8C, 0x6A, 0x4E, 0xFD, 0x67, 0xF9, 0xA6, 0xF3, 0xD3 };   //OTAA appkey    
+//==============================================================================
+//printNmvData
 //==============================================================================
-//getChkSum
+void printNmvData(nvm *pNvm){
+     uint8_t i;
+     pc.printf("\r\nnon-volatile memory (nvm):"); 
+     pc.printf("\r\nnetwork_id:"); 
+    // for (i = 0 ; i < sizeof(nvm.network_id);i++)i =1;
+     //pc.printf(pNvm->network[i];
+    
+}                              
+//==============================================================================
+//getNvmChkSum
 //compute chksum for nvm data; don't include chksum byte in nvm struc
 //==============================================================================
-uint8_t getChkSum(nvm *pNvm){
-   uint8_t i;
+uint8_t getNvmChkSum(nvm *pNvm){
+    uint8_t i;
     uint8_t chksum= 0;   
     uint8_t *pData = (uint8_t *)pNvm;
     
@@ -29,7 +40,7 @@
 //write nvmData struc to nvm memory
 //==============================================================================
 bool nvmWrite(nvm *pNvm){   
-   pNvm->chksum = getChkSum(pNvm);
+   pNvm->chksum = getNvmChkSum(pNvm);
    return dot->nvmWrite(0,pNvm,sizeof(nvm));      
 }
 //==============================================================================
@@ -40,13 +51,13 @@
 bool nvmRead(nvm *pNvm){     
    uint8_t i;  
    dot->nvmRead(0,pNvm,sizeof(nvm));  
-   uint8_t chksum = getChkSum(pNvm);
+   uint8_t chksum = getNvmChkSum(pNvm);
    if (chksum == pNvm->chksum){
-       logInfo("nmvRead: chksum ok");    
+       logInfo("nvmRead: chksum ok");    
        return true;
    }    
 //bad chksum, resort to old hard coded keys  
-   logInfo("nmvRead: bad chksum, using default values");      
+   pc.printf("nvmRead: bad chksum, using default values");      
    for (i = 0; i < sizeof(network_id);i++){
         pNvm->network_id[i] = network_id[i];   
     }