Fork to see if I can get working

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

Fork of xDotBridge_update_test20180823 by Matt Briggs

Files at this revision

API Documentation at this revision

Comitter:
mbriggs_vortex
Date:
Tue Nov 28 16:15:23 2017 +0000
Parent:
94:8028c07f71fa
Child:
97:594e47206604
Commit message:
Added sets of resets to mitigate pairing issues. Sort of a hacky solution. Will improve later.

Changed in this revision

xDotBridge/src/CommProtocolPeerBrute.cpp Show annotated file Show diff for this revision Revisions of this file
xDotBridge/src/main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/xDotBridge/src/CommProtocolPeerBrute.cpp	Wed Nov 22 01:11:36 2017 +0000
+++ b/xDotBridge/src/CommProtocolPeerBrute.cpp	Tue Nov 28 16:15:23 2017 +0000
@@ -9,7 +9,7 @@
 #include "dot_util.h"
 #include "util.h"
 #include "MyLog.h"
-#include "ChannelPlan.h"
+#include "ChannelPlans.h"
 
 // wireless bridge protocol
 const uint8_t TX_PWR = 20; // 20 dBm
@@ -57,6 +57,7 @@
 
 //    myLogInfo("defaulting Dot configuration");
 //    dot->resetConfig();
+//    dot->setWakePin(GPIO0);
 
     // Common Configuration
     dot->setAesEncryption(true);  // Enable encryption
@@ -86,7 +87,7 @@
             // DR6 : SF7 @ 250kHz
             // DR0 - DR5 (125kHz channels) available but much slower
             tx_frequency = 869850000;
-            tx_datarate = mDot::DR6;
+            tx_datarate = lora::DR_6;
             // the 869850000 frequency is 100% duty cycle if the total power is under 7 dBm - tx power 4 + antenna gain 3 = 7
             tx_power = 4;
             break;
@@ -94,7 +95,6 @@
         case lora::ChannelPlan::US915:
         case lora::ChannelPlan::AU915_OLD:
         case lora::ChannelPlan::AU915:
-        default:
             // 500kHz channels achieve highest throughput
             // DR8 : SF12 @ 500kHz
             // DR9 : SF11 @ 500kHz
@@ -104,10 +104,13 @@
             // DR13 : SF7 @ 500kHz
             // DR0 - DR3 (125kHz channels) available but much slower
             tx_frequency = 915500000;
-            tx_datarate = mDot::DR13;
+            tx_datarate = lora::DR_13;
             // 915 bands have no duty cycle restrictions, set tx power to max
             tx_power = 20;
             break;
+        default:
+        	logError("ChannelPlan Error!!!");
+			return cmdError;
     }
     // in PEER_TO_PEER mode there is no join request/response transaction
     // as long as both Dots are configured correctly, they should be able to communicate
@@ -123,8 +126,9 @@
         return cmdError;
     }
 
-//    myLogInfo("defaulting Dot configuration");
-//    dot->resetConfig();
+    myLogInfo("defaulting Dot configuration"); // TEST
+    dot->resetConfig();
+    dot->setWakePin(GPIO0);
 
     // Common Configuration
     dot->setAesEncryption(true);  // Enable encryption
@@ -133,8 +137,6 @@
     dot->setClass("C"); // Set class C
     dot->setTxPower(TX_PWR);
     dot->setPreserveSession(false);
-//    dot->setDownLinkCounter(0);
-//    dot->setUpLinkCounter(1);
     // TODO break out in a utility function
     // update configuration if necessary
     myLogDebug("Setting up peer to peer configuration");
@@ -156,7 +158,7 @@
             // DR6 : SF7 @ 250kHz
             // DR0 - DR5 (125kHz channels) available but much slower
             tx_frequency = 869850000;
-            tx_datarate = mDot::DR6;
+            tx_datarate = lora::DR_6;
             // the 869850000 frequency is 100% duty cycle if the total power is under 7 dBm - tx power 4 + antenna gain 3 = 7
             tx_power = 4;
             break;
@@ -164,7 +166,6 @@
         case lora::ChannelPlan::US915:
         case lora::ChannelPlan::AU915_OLD:
         case lora::ChannelPlan::AU915:
-        default:
             // 500kHz channels achieve highest throughput
             // DR8 : SF12 @ 500kHz
             // DR9 : SF11 @ 500kHz
@@ -174,10 +175,14 @@
             // DR13 : SF7 @ 500kHz
             // DR0 - DR3 (125kHz channels) available but much slower
             tx_frequency = 915500000;
-            tx_datarate = mDot::DR13;
+            tx_datarate = lora::DR_13;
             // 915 bands have no duty cycle restrictions, set tx power to max
             tx_power = 20;
             break;
+        default:
+        	logError("ChannelPlan Error!!!");
+			return cmdError;
+
     }
     update_peer_to_peer_config(pair_network_address, pair_network_session_key, pair_data_session_key, tx_frequency, tx_datarate, tx_power);
     dot->saveConfig(); // This is required for network settings to apply
--- a/xDotBridge/src/main.cpp	Wed Nov 22 01:11:36 2017 +0000
+++ b/xDotBridge/src/main.cpp	Tue Nov 28 16:15:23 2017 +0000
@@ -18,7 +18,7 @@
 
 #define RX_SEQ_LOG 1
 
-const float BridgeVersion = 1.98; // Bumped 2017/11/TODO
+const float BridgeVersion = 1.96; // Bumped 2017/11/TODO
 
 // 232 Pins
 const PinName SER_TERM_TX = UART_TX;
@@ -30,6 +30,7 @@
 InterruptIn uart1RxIntIn (SER_TERM_RX);
 
 mDot* dot = NULL; // Used by dot-utils
+lora::ChannelPlan* plan = NULL;
 
 volatile bool uartRxFlag;
 volatile bool ccIntFlag;
@@ -71,7 +72,7 @@
     MyLog::setLogLevel(MyLog::DEBUG_LEVEL);
 
 	// use US915 plan
-    lora::ChannelPlan* plan = new lora::ChannelPlan_US915();
+    plan = new lora::ChannelPlan_US915();
     // use EU868 plan
     // lora::ChannelPlan* plan = new lora::ChannelPlan_EU868();
     assert(plan);
@@ -101,7 +102,6 @@
 
     dot->setWakeMode(mDot::RTC_ALARM_OR_INTERRUPT);
     dot->setWakePin(GPIO0);
-//    dot->setWakePin(UART_RX);
 
     display_config();  // Print configuration for now
 
@@ -194,6 +194,8 @@
                     rxSeqLog.clear();
                     rxSeqLog.save();
                     myLogInfo("NVM Cleared Seq Log");
+                    myLogInfo("Resetting...");
+                    dot->resetCpu();
                 }
             }
             if (protocol->isRx()) {
@@ -221,6 +223,8 @@
                     rxSeqLog.clear();
                     rxSeqLog.save();
                     myLogInfo("NVM Cleared Seq Log");
+                    myLogInfo("Resetting...");
+                    dot->resetCpu();
                 }
                 else if (pairBtnState == pairBtnLongPress) {
                     myLogInfo("Clearing pair values and generating new ones.");