Fork to see if I can get working

Dependencies:   BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated

Fork of xDotBridge_update_test20180823 by Matt Briggs

Revision:
62:9751a8504c82
Parent:
61:8d9efd33cac9
Child:
63:e1efbe3402d9
--- a/xDotBridge/inc/CommProtocolPeerBrute.h	Thu Mar 09 16:47:42 2017 -0700
+++ b/xDotBridge/inc/CommProtocolPeerBrute.h	Tue Mar 14 08:32:55 2017 -0600
@@ -14,14 +14,14 @@
 // TODO wrap radio commands for error checking
 
 // TODO change to const
-static uint8_t pair_network_address[] = { 0x01, 0x02, 0x03, 0x04 };
+static uint8_t pair_network_address[] = { 0x01, 0x00, 0x00, 0x00 }; // 0x00000000 reserved for multicast so use 1
 static uint8_t pair_network_session_key[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 };
 static uint8_t pair_data_session_key[] =    { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 };
 
 const uint16_t PROTOCOL_NVM_START_ADDR = 0x1000;
-const uint16_t PROTOCOL_NVM_SIZE = 12; // Bytes
+const uint16_t PROTOCOL_NVM_SIZE = 54; // Bytes
 const uint16_t PROTOCOL_FLAG = 0x5A00;
-const uint16_t PROTOCOL_REV = 0x0000;
+const uint16_t PROTOCOL_REV = 0x0002;
 class NvmProtocolObj {
 public:
     NvmProtocolObj();
@@ -34,13 +34,26 @@
     uint16_t getProtocolRev();
     bool validProtocolRev();
 
+    void getNetworkAddr(std::vector<uint8_t> &addr);
+    void setNetworkAddr(const std::vector<uint8_t> &addr);
+    void getNetworkSessionKey(std::vector<uint8_t> &key);
+    void setNetworkSessionKey(const std::vector<uint8_t> &key);
+    void getDataSessionKey(std::vector<uint8_t> &key);
+    void setDataSessionKey(const std::vector<uint8_t> &key);
+
     uint16_t getLogicalAddr();
     void setLogicalAddr(uint16_t in);
     uint32_t getLastMsgSeq();
     void setLastMsgSeq(uint32_t in);
+
+    // TODO some day make these private with setters and getters
+    uint8_t  mNetworkAddr[4];
+    uint8_t  mNetworkSessionKey[16];
+    uint8_t  mDataSessionKey[16];
 private:
     uint16_t mProtocolFlag;
     uint16_t mProtocolRev;
+    uint32_t mFreq;
     uint16_t mLogicalAddr;
     uint32_t mSeqNum;
 };
@@ -90,7 +103,7 @@
      * @return Returns the result of all the commands
      */
     CmdResult init();
-    CmdResult dotDefaults();
+    CmdResult configForSavedNetwork();
 
     /**
      * @brief Sets weather this object is configured as a TX or RX
@@ -192,10 +205,10 @@
      */
     uint32_t getULC();
 
+    // TODO maybe this should be private
+    CmdResult configForPairingNetwork();
+
 private:
-//    uint8_t mNetworkAddr[4];
-//    uint8_t mNetwork_session_key[16];
-//    uint8_t mData_session_key[16];
     NvmProtocolObj mMemObj;
     bool mIsTx;
     uint32_t mPrevDownLinkCnt;
@@ -242,10 +255,9 @@
      * Generates new encryption keys for radio
      * @return
      */
+    CmdResult genEncypKey(std::vector<uint8_t> &newKey, uint8_t keySize, bool allowZero);
     CmdResult genEncypKey(std::vector<uint8_t> &newKey, uint8_t keySize);
 
-    CmdResult configForPairingNetwork();
-    CmdResult configForSavedNetwork();
 };