diff options
author | Mike Fiore <mfiore@multitech.com> | 2015-12-11 10:18:02 -0600 |
---|---|---|
committer | Mike Fiore <mfiore@multitech.com> | 2015-12-11 10:18:02 -0600 |
commit | c28f3e07a6320f48476fd4dad5cca0011669e49f (patch) | |
tree | 063962dd2197419f62cd2555b8525df89db18ea1 | |
parent | a1bb849d38853c79285665e702f9425770e74133 (diff) | |
parent | 279d4b746cb23dce634c968a86eaab0199f1d4af (diff) | |
download | mtdot-box-evb-factory-firmware-c28f3e07a6320f48476fd4dad5cca0011669e49f.tar.gz mtdot-box-evb-factory-firmware-c28f3e07a6320f48476fd4dad5cca0011669e49f.tar.bz2 mtdot-box-evb-factory-firmware-c28f3e07a6320f48476fd4dad5cca0011669e49f.zip |
Merge branch 'link_check'
Conflicts:
Layout/LayoutSurveySuccess.cpp
Mode/Mode.cpp
-rw-r--r-- | ButtonHandler/ButtonHandler.cpp | 2 | ||||
-rw-r--r-- | Layout/LayoutSurveySuccess.cpp | 19 | ||||
-rw-r--r-- | Layout/LayoutSurveySuccess.h | 5 | ||||
-rw-r--r-- | LoRaHandler/LoRaHandler.cpp | 34 | ||||
-rw-r--r-- | LoRaHandler/LoRaHandler.h | 14 | ||||
-rw-r--r-- | Mode/Mode.cpp | 19 | ||||
-rw-r--r-- | Mode/Mode.h | 4 | ||||
-rw-r--r-- | Mode/ModeSingle.cpp | 10 | ||||
-rw-r--r-- | Mode/ModeSweep.cpp | 10 |
9 files changed, 55 insertions, 62 deletions
diff --git a/ButtonHandler/ButtonHandler.cpp b/ButtonHandler/ButtonHandler.cpp index edc9ea1..279fc5b 100644 --- a/ButtonHandler/ButtonHandler.cpp +++ b/ButtonHandler/ButtonHandler.cpp @@ -96,7 +96,7 @@ ButtonHandler::ButtonHandler(osThreadId main) // fall handler called on press, rise handler called on release _sw1.fall(this, &ButtonHandler::sw1_fall); _sw1.rise(this, &ButtonHandler::sw1_rise); - // need to set mode to PullUp after attaching handlers - won't work otherwise + // need to set mode to PullUp after attaching handlers - default is PullNone (see PinNames.h) _sw1.mode(PullUp); _sw2.fall(this, &ButtonHandler::sw2_fall); diff --git a/Layout/LayoutSurveySuccess.cpp b/Layout/LayoutSurveySuccess.cpp index be86b79..e59a754 100644 --- a/Layout/LayoutSurveySuccess.cpp +++ b/Layout/LayoutSurveySuccess.cpp @@ -6,13 +6,12 @@ LayoutSurveySuccess::LayoutSurveySuccess(DOGS102* lcd) _lId(0, 0, "ID"), _lDr(8, 0, "DR"), _lPwr(13, 0, "P"), - _lUp(0, 1, "UP"), + _lUp(0, 1, "UP Margin"), _lDown(0, 2, "DWN"), _fId(2, 0, 5), _fDr(10, 0, 2), _fPwr(14, 0, 2), - _fUpRssi(3, 1, 7), - _fUpSnr(11, 1, 5), + _fUpMargin(10, 1, 5), _fDownRssi(4, 2, 7), _fDownSnr(12, 2, 5), _fGpsLat(0, 4, 17), @@ -58,25 +57,21 @@ void LayoutSurveySuccess::updatePower(uint32_t power) { writeField(_fPwr, buf, size, true); } -void LayoutSurveySuccess::updateStats(LoRaHandler::LoRaPing ping) { +void LayoutSurveySuccess::updateStats(LoRaHandler::LoRaLink link) { char buf[16]; size_t size; startUpdate(); - size = snprintf(buf, sizeof(buf), "%3d dbm", ping.up.rssi); - writeField(_fUpRssi, buf, size); + size = snprintf(buf, sizeof(buf), "%d", link.up.dBm); + writeField(_fUpMargin, buf, size); memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%2.1f", (float)ping.up.snr / 10.0); - writeField(_fUpSnr, buf, size); - - memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%3d dbm", ping.down.rssi); + size = snprintf(buf, sizeof(buf), "%3d dbm", link.down.rssi); writeField(_fDownRssi, buf, size); memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%2.1f", (float)ping.down.snr / 10.0); + size = snprintf(buf, sizeof(buf), "%2.1f", (float)link.down.snr / 10.0); writeField(_fDownSnr, buf, size); endUpdate(); diff --git a/Layout/LayoutSurveySuccess.h b/Layout/LayoutSurveySuccess.h index 49113cb..a330c7f 100644 --- a/Layout/LayoutSurveySuccess.h +++ b/Layout/LayoutSurveySuccess.h @@ -14,7 +14,7 @@ class LayoutSurveySuccess : public Layout { void updateId(uint32_t id); void updateRate(std::string rate); void updatePower(uint32_t power); - void updateStats(LoRaHandler::LoRaPing ping); + void updateStats(LoRaHandler::LoRaLink link); void updateGpsLatitude(GPSPARSER::latitude lat); void updateGpsLatitude(std::string msg); void updateGpsLongitude(GPSPARSER::longitude lon); @@ -35,8 +35,7 @@ class LayoutSurveySuccess : public Layout { Field _fId; Field _fDr; Field _fPwr; - Field _fUpRssi; - Field _fUpSnr; + Field _fUpMargin; Field _fDownRssi; Field _fDownSnr; Field _fGpsLat; diff --git a/LoRaHandler/LoRaHandler.cpp b/LoRaHandler/LoRaHandler.cpp index b4de8b3..472af3e 100644 --- a/LoRaHandler/LoRaHandler.cpp +++ b/LoRaHandler/LoRaHandler.cpp @@ -4,7 +4,7 @@ typedef enum { l_none = 0, - l_ping, + l_link_check, l_send, l_join } InternalLoRa; @@ -18,7 +18,7 @@ void l_worker(void const* argument) { l->_dot = mDot::getInstance(); int32_t ret; - mDot::ping_response pr; + mDot::link_check lc; mDot::rssi_stats rs; mDot::snr_stats ss; @@ -28,21 +28,21 @@ void l_worker(void const* argument) { l->_status = LoRaHandler::busy; l->_tick.attach(l, &LoRaHandler::blinker, 0.05); switch (cmd) { - case l_ping: + case l_link_check: l->_mutex.lock(); - pr = l->_dot->ping(); + lc = l->_dot->networkLinkCheck(); l->_mutex.unlock(); - if (pr.status == mDot::MDOT_OK) { - l->_ping.up = pr; + if (lc.status) { + l->_link.up = lc; l->_mutex.lock(); rs = l->_dot->getRssiStats(); ss = l->_dot->getSnrStats(); l->_mutex.unlock(); - l->_ping.down.rssi = rs.last; - l->_ping.down.snr = ss.last; - l->_status = LoRaHandler::ping_success; + l->_link.down.rssi = rs.last; + l->_link.down.snr = ss.last; + l->_status = LoRaHandler::link_check_success; } else { - l->_status = LoRaHandler::ping_failure; + l->_status = LoRaHandler::link_check_failure; } osSignalSet(l->_main, loraSignal); l->_tick.detach(); @@ -92,12 +92,12 @@ LoRaHandler::LoRaHandler(osThreadId main) _join_attempts(1), _activity_led(XBEE_DIO1, PIN_OUTPUT, PullNone, red) { - _ping.status = false; + _link.status = false; _activity_led = red; } -bool LoRaHandler::ping() { - return action(l_ping); +bool LoRaHandler::linkCheck() { + return action(l_link_check); } bool LoRaHandler::send(std::vector<uint8_t> data) { @@ -129,13 +129,13 @@ LoRaHandler::LoRaStatus LoRaHandler::getStatus() { return status; } -LoRaHandler::LoRaPing LoRaHandler::getPingResults() { - LoRaPing ping; +LoRaHandler::LoRaLink LoRaHandler::getLinkCheckResults() { + LoRaLink link; _mutex.lock(); - ping = _ping; + link = _link; _mutex.unlock(); - return ping; + return link; } uint32_t LoRaHandler::getJoinAttempts() { diff --git a/LoRaHandler/LoRaHandler.h b/LoRaHandler/LoRaHandler.h index 375c277..aa82398 100644 --- a/LoRaHandler/LoRaHandler.h +++ b/LoRaHandler/LoRaHandler.h @@ -10,19 +10,19 @@ class LoRaHandler { typedef enum { none = 0, busy, - ping_success, + link_check_success, send_success, join_success, - ping_failure, + link_check_failure, send_failure, join_failure } LoRaStatus; typedef struct { bool status; - mDot::ping_response up; + mDot::link_check up; mDot::ping_response down; - } LoRaPing; + } LoRaLink; typedef enum { green = 0, @@ -32,12 +32,12 @@ class LoRaHandler { LoRaHandler(osThreadId main); ~LoRaHandler(); - bool ping(); + bool linkCheck(); bool send(std::vector<uint8_t> data); bool join(); bool action(uint8_t cmd); LoRaStatus getStatus(); - LoRaPing getPingResults(); + LoRaLink getLinkCheckResults(); uint32_t getJoinAttempts(); void resetJoinAttempts(); void blinker(); @@ -46,7 +46,7 @@ class LoRaHandler { osThreadId _main; Thread _thread; LoRaStatus _status; - LoRaPing _ping; + LoRaLink _link; mDot* _dot; Mutex _mutex; uint32_t _join_attempts; diff --git a/Mode/Mode.cpp b/Mode/Mode.cpp index 4d5af8a..ef343fd 100644 --- a/Mode/Mode.cpp +++ b/Mode/Mode.cpp @@ -94,12 +94,11 @@ bool Mode::appendDataFile(const DataItem& data) { } if (data.status) { - float up_snr = (float)data.ping.up.snr / 10.0; - float down_snr = (float)data.ping.down.snr / 10.0; - snprintf(stats_buf, sizeof(stats_buf), "%d,%2.1f,%d,%2.1f", - abs(data.ping.up.rssi), - up_snr, - abs(data.ping.down.rssi), + float down_snr = (float)data.link.down.snr / 10.0; + snprintf(stats_buf, sizeof(stats_buf), "%d,%d,%d,%2.1f", + data.link.up.gateways, + data.link.up.dBm, + abs(data.link.down.rssi), down_snr); } @@ -140,7 +139,7 @@ void Mode::updateData(DataItem& data, DataType type, bool status) { data.gps_latitude = _gps->getLatitude(); data.gps_altitude = _gps->getAltitude(); data.gps_time = _gps->getTimestamp(); - data.ping = _ping_result; + data.link = _link_check_result; data.data_rate = _data_rate; data.power = _power; } @@ -240,14 +239,14 @@ std::vector<uint8_t> Mode::formatSurveyData(DataItem& data) { send_data.clear(); send_data.push_back(0x1D); // key for start of data structure send_data.push_back(0x1A); // key for uplink QOS + RF Pwr - convertS.f_s = data.ping.up.rssi; + convertS.f_s = data.link.up.gateways; send_data.push_back(convertS.t_u[1]); send_data.push_back(convertS.t_u[0]); - send_data.push_back((data.ping.up.snr/10) & 0xFF); + send_data.push_back((data.link.up.dBm) & 0xFF); send_data.push_back(data.power); send_data.push_back(0x1B); // key for downlink QOS - convertS.f_s=data.ping.down.rssi; + convertS.f_s=data.link.down.rssi; send_data.push_back(convertS.t_u[1]); send_data.push_back(convertS.t_u[0]); send_data.push_back((data.ping.down.snr/10) & 0xFF); diff --git a/Mode/Mode.h b/Mode/Mode.h index e552732..759592a 100644 --- a/Mode/Mode.h +++ b/Mode/Mode.h @@ -29,7 +29,7 @@ class Mode { GPSPARSER::latitude gps_latitude; int16_t gps_altitude; struct tm gps_time; - LoRaHandler::LoRaPing ping; + LoRaHandler::LoRaLink link; uint8_t data_rate; uint32_t power; } DataItem; @@ -75,7 +75,7 @@ class Mode { uint32_t _next_tx; ButtonHandler::ButtonEvent _be; LoRaHandler::LoRaStatus _ls; - LoRaHandler::LoRaPing _ping_result; + LoRaHandler::LoRaLink _link_check_result; uint8_t _state; bool _send_data; bool _gps_available; diff --git a/Mode/ModeSingle.cpp b/Mode/ModeSingle.cpp index 105fa16..52f7c21 100644 --- a/Mode/ModeSingle.cpp +++ b/Mode/ModeSingle.cpp @@ -129,10 +129,10 @@ bool ModeSingle::start() { if (e.value.signals & loraSignal) { _ls = _lora->getStatus(); switch (_ls) { - case LoRaHandler::ping_success: + case LoRaHandler::link_check_success: switch (_state) { case in_progress: - _ping_result = _lora->getPingResults(); + _link_check_result = _lora->getLinkCheckResults(); displaySuccess(); logInfo("ping successful"); updateData(_data, single, true); @@ -152,7 +152,7 @@ bool ModeSingle::start() { } break; - case LoRaHandler::ping_failure: + case LoRaHandler::link_check_failure: switch (_state) { case in_progress: _state = failure; @@ -240,7 +240,7 @@ bool ModeSingle::start() { send_ping = false; _dot->setTxDataRate(_data_rate); _dot->setTxPower(_power); - _lora->ping(); + _lora->linkCheck(); _index++; } if (send_data) { @@ -277,7 +277,7 @@ void ModeSingle::displaySuccess() { // mDot::DataRateStr returns format SF_XX - we only want to display the XX part _success.updateRate(_dot->DataRateStr(_data_rate).substr(3)); _success.updatePower(_power); - _success.updateStats(_ping_result); + _success.updateStats(_link_check_result); if (_gps_available && _gps->getLockStatus()) { GPSPARSER::latitude lat = _gps->getLatitude(); GPSPARSER::longitude lon = _gps->getLongitude(); diff --git a/Mode/ModeSweep.cpp b/Mode/ModeSweep.cpp index 45fdee0..4ccb05e 100644 --- a/Mode/ModeSweep.cpp +++ b/Mode/ModeSweep.cpp @@ -162,11 +162,11 @@ bool ModeSweep::start() { if (e.value.signals & loraSignal) { _ls = _lora->getStatus(); switch (_ls) { - case LoRaHandler::ping_success: + case LoRaHandler::link_check_success: switch (_state) { case in_progress: _survey_success++; - _ping_result = _lora->getPingResults(); + _link_check_result = _lora->getLinkCheckResults(); displaySuccess(); logInfo("ping successful"); updateData(_data, sweep, true); @@ -186,7 +186,7 @@ bool ModeSweep::start() { } break; - case LoRaHandler::ping_failure: + case LoRaHandler::link_check_failure: switch (_state) { case in_progress: _survey_failure++; @@ -300,7 +300,7 @@ bool ModeSweep::start() { send_ping = false; _dot->setTxDataRate(_data_rate); _dot->setTxPower(_power); - _lora->ping(); + _lora->linkCheck(); } if (send_data) { std::vector<uint8_t> s_data = formatSurveyData(_data); @@ -332,7 +332,7 @@ void ModeSweep::displaySuccess() { // mDot::DataRateStr returns format SF_XX - we only want to display the XX part _success.updateRate(_dot->DataRateStr(_data_rate).substr(3)); _success.updatePower(_power); - _success.updateStats(_ping_result); + _success.updateStats(_link_check_result); if (_gps_available && _gps->getLockStatus()) { GPSPARSER::latitude lat = _gps->getLatitude(); GPSPARSER::longitude lon = _gps->getLongitude(); |