summaryrefslogtreecommitdiff
path: root/LoRaHandler
diff options
context:
space:
mode:
authorMike Fiore <mfiore@multitech.com>2015-11-20 08:13:35 -0600
committerMike Fiore <mfiore@multitech.com>2015-11-20 08:13:35 -0600
commit674cdb5c13bad3598381b81d843b5aeee5798d1f (patch)
tree1d18d592b5df2513036838bc94530648ad36631e /LoRaHandler
parent11412cbac7021dd8aee14ac4f1dc25994c9ab45b (diff)
downloadmtdot-box-evb-factory-firmware-674cdb5c13bad3598381b81d843b5aeee5798d1f.tar.gz
mtdot-box-evb-factory-firmware-674cdb5c13bad3598381b81d843b5aeee5798d1f.tar.bz2
mtdot-box-evb-factory-firmware-674cdb5c13bad3598381b81d843b5aeee5798d1f.zip
implement basic single survey mode - still needs sending data packet and data survey file
Diffstat (limited to 'LoRaHandler')
-rw-r--r--LoRaHandler/LoRaHandler.cpp20
-rw-r--r--LoRaHandler/LoRaHandler.h3
2 files changed, 22 insertions, 1 deletions
diff --git a/LoRaHandler/LoRaHandler.cpp b/LoRaHandler/LoRaHandler.cpp
index 27eb266..7ba05f5 100644
--- a/LoRaHandler/LoRaHandler.cpp
+++ b/LoRaHandler/LoRaHandler.cpp
@@ -60,6 +60,7 @@ void l_worker(void const* argument) {
case l_join:
l->_mutex.lock();
ret = l->_dot->joinNetworkOnce();
+ l->_join_attempts++;
l->_mutex.unlock();
if (ret == mDot::MDOT_OK) {
l->_status = LoRaHandler::join_success;
@@ -80,7 +81,8 @@ void l_worker(void const* argument) {
LoRaHandler::LoRaHandler(osThreadId main)
: _main(main),
_thread(l_worker, (void*)this),
- _status(none)
+ _status(none),
+ _join_attempts(1)
{
_ping.status = false;
}
@@ -158,3 +160,19 @@ uint32_t LoRaHandler::getNextTx() {
return ms;
}
+uint32_t LoRaHandler::getJoinAttempts() {
+ uint32_t val;
+
+ _mutex.lock();
+ val = _join_attempts;
+ _mutex.unlock();
+
+ return val;
+}
+
+void LoRaHandler::resetJoinAttempts() {
+ _mutex.lock();
+ _join_attempts = 1;
+ _mutex.unlock();
+}
+
diff --git a/LoRaHandler/LoRaHandler.h b/LoRaHandler/LoRaHandler.h
index 20f9d6f..1a68668 100644
--- a/LoRaHandler/LoRaHandler.h
+++ b/LoRaHandler/LoRaHandler.h
@@ -36,6 +36,8 @@ class LoRaHandler {
LoRaStatus getStatus();
LoRaPing getPingResults();
uint32_t getNextTx();
+ uint32_t getJoinAttempts();
+ void resetJoinAttempts();
osThreadId _main;
@@ -44,6 +46,7 @@ class LoRaHandler {
LoRaPing _ping;
mDot* _dot;
Mutex _mutex;
+ uint32_t _join_attempts;
};
#endif