summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Fiore <mfiore@multitech.com>2015-12-08 12:56:29 -0600
committerMike Fiore <mfiore@multitech.com>2015-12-08 12:56:29 -0600
commitabaacd64f96b834d85169f12351b0057c6e9c2fd (patch)
tree4bb98e806182401155e144f84a28114a9d3c4be9
parent5a74150c78737daf2764570835b59b45141f3775 (diff)
downloadmtdot-box-evb-factory-firmware-abaacd64f96b834d85169f12351b0057c6e9c2fd.tar.gz
mtdot-box-evb-factory-firmware-abaacd64f96b834d85169f12351b0057c6e9c2fd.tar.bz2
mtdot-box-evb-factory-firmware-abaacd64f96b834d85169f12351b0057c6e9c2fd.zip
use link check instead of ping for compatibility with 3rd party network servers
-rw-r--r--Layout/LayoutSurveySuccess.cpp19
-rw-r--r--Layout/LayoutSurveySuccess.h5
-rw-r--r--LoRaHandler/LoRaHandler.cpp34
-rw-r--r--LoRaHandler/LoRaHandler.h14
-rw-r--r--Mode/Mode.cpp21
-rw-r--r--Mode/Mode.h4
-rw-r--r--Mode/ModeSingle.cpp10
-rw-r--r--Mode/ModeSweep.cpp10
8 files changed, 55 insertions, 62 deletions
diff --git a/Layout/LayoutSurveySuccess.cpp b/Layout/LayoutSurveySuccess.cpp
index 01a0c94..3ba1008 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 / 4.0);
+ size = snprintf(buf, sizeof(buf), "%2.1f", (float)link.down.snr / 4.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 70a3f49..2bac839 100644
--- a/Mode/Mode.cpp
+++ b/Mode/Mode.cpp
@@ -92,12 +92,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 / 4.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 / 4.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);
}
@@ -138,7 +137,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;
}
@@ -227,17 +226,17 @@ 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);
+ send_data.push_back(data.link.down.snr);
// collect GPS data if GPS device detected
if (_gps->gpsDetected() && ((_data_rate != mDot::SF_10) || (_band == mDot::FB_868))){
diff --git a/Mode/Mode.h b/Mode/Mode.h
index 61687f1..bd09cc9 100644
--- a/Mode/Mode.h
+++ b/Mode/Mode.h
@@ -28,7 +28,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;
@@ -68,7 +68,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 737301f..70d131c 100644
--- a/Mode/ModeSingle.cpp
+++ b/Mode/ModeSingle.cpp
@@ -124,10 +124,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);
@@ -147,7 +147,7 @@ bool ModeSingle::start() {
}
break;
- case LoRaHandler::ping_failure:
+ case LoRaHandler::link_check_failure:
switch (_state) {
case in_progress:
_state = failure;
@@ -235,7 +235,7 @@ bool ModeSingle::start() {
send_ping = false;
_dot->setTxDataRate(_data_rate);
_dot->setTxPower(_power);
- _lora->ping();
+ _lora->linkCheck();
_index++;
}
if (send_data) {
@@ -272,7 +272,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 17047b3..80c2dde 100644
--- a/Mode/ModeSweep.cpp
+++ b/Mode/ModeSweep.cpp
@@ -157,11 +157,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);
@@ -181,7 +181,7 @@ bool ModeSweep::start() {
}
break;
- case LoRaHandler::ping_failure:
+ case LoRaHandler::link_check_failure:
switch (_state) {
case in_progress:
_survey_failure++;
@@ -295,7 +295,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);
@@ -327,7 +327,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();