From 674cdb5c13bad3598381b81d843b5aeee5798d1f Mon Sep 17 00:00:00 2001 From: Mike Fiore Date: Fri, 20 Nov 2015 08:13:35 -0600 Subject: implement basic single survey mode - still needs sending data packet and data survey file --- LoRaHandler/LoRaHandler.cpp | 20 +++++++++++++++++++- LoRaHandler/LoRaHandler.h | 3 +++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'LoRaHandler') 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 -- cgit v1.2.3