summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Reiss <jreiss@multitech.com>2016-09-21 13:52:59 -0500
committerJason Reiss <jreiss@multitech.com>2016-09-21 13:52:59 -0500
commit04b6e95c2931eadee93a6c1fe982f1658a60e1b7 (patch)
tree84406fd9a31a44d78422003249572f2b104be850
parentbe0d56b806ce76cef1d5bd5b6795391c2049b8b4 (diff)
parent692b74778f6b95cf0c668dfdb85f39035e113baa (diff)
downloadmtdot-box-evb-factory-firmware-04b6e95c2931eadee93a6c1fe982f1658a60e1b7.tar.gz
mtdot-box-evb-factory-firmware-04b6e95c2931eadee93a6c1fe982f1658a60e1b7.tar.bz2
mtdot-box-evb-factory-firmware-04b6e95c2931eadee93a6c1fe982f1658a60e1b7.zip
Merge branch 'Semtech'
Conflicts: .gitmodules Mode/ModeJoin.cpp main.cpp Add AU915
-rw-r--r--.gitmodules4
-rw-r--r--CommandTerminal/CmdDisplayConfig.cpp2
-rw-r--r--CommandTerminal/CmdFactoryDefault.cpp2
-rw-r--r--CommandTerminal/CmdFrequencyBand.cpp31
-rw-r--r--CommandTerminal/CmdSendContinuous.cpp13
-rw-r--r--CommandTerminal/CmdSendContinuous.h18
-rw-r--r--CommandTerminal/CmdTxDataRate.cpp136
-rw-r--r--CommandTerminal/CmdTxFrequency.cpp26
-rw-r--r--CommandTerminal/CmdTxFrequency.h20
-rw-r--r--CommandTerminal/CmdWriteProtectedConfig.cpp4
-rw-r--r--CommandTerminal/CmdWriteProtectedConfig.h1
-rw-r--r--CommandTerminal/Commands.h2
-rw-r--r--FileName.h2
-rw-r--r--Layout/LayoutSemtech.cpp200
-rw-r--r--Layout/LayoutSemtech.h78
-rw-r--r--Layout/LayoutSemtechJoin.cpp91
-rw-r--r--Layout/LayoutSemtechJoin.h59
-rw-r--r--Mode/Mode.cpp6
-rw-r--r--Mode/ModeConfig.cpp2
-rw-r--r--Mode/ModeDemo.cpp6
-rw-r--r--Mode/ModeGps.cpp6
-rw-r--r--Mode/ModeJoin.cpp2
-rw-r--r--Mode/ModeSemtech.cpp339
-rw-r--r--Mode/ModeSemtech.h76
-rw-r--r--Mode/ModeSingle.cpp35
-rw-r--r--Mode/ModeSweep.cpp32
-rw-r--r--main.cpp30
m---------mdot-library0
-rw-r--r--parser_function.txt2
29 files changed, 1105 insertions, 120 deletions
diff --git a/.gitmodules b/.gitmodules
index ed78bc8..69cfdcd 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,6 @@
[submodule "mdot-library"]
path = mdot-library
- url = git@gitlab.multitech.net:/lora-mote/mdot-library.git
+ url = git@gitlab.multitech.net:lora-mote/mdot-library.git
[submodule "libs/MTS-Serial"]
path = libs/MTS-Serial
- url = git@gitlab.multitech.net:/mbed/MTS-Serial.git
+ url = git@gitlab.multitech.net:mbed/MTS-Serial.git
diff --git a/CommandTerminal/CmdDisplayConfig.cpp b/CommandTerminal/CmdDisplayConfig.cpp
index 31fc100..58ba86d 100644
--- a/CommandTerminal/CmdDisplayConfig.cpp
+++ b/CommandTerminal/CmdDisplayConfig.cpp
@@ -38,7 +38,7 @@ uint32_t CmdDisplayConfig::action(std::vector<std::string> args) {
_serial.writef("%s\r\n", mts::Text::bin2hexString(_dot->getDeviceId(), ":").c_str());
_serial.writef("Frequency Band:\t\t%s\r\n", mDot::FrequencyBandStr(_dot->getFrequencyBand()).c_str());
- if (_dot->getFrequencyBand() == mDot::FB_915)
+ if (_dot->getFrequencyBand() == mDot::FB_US915)
_serial.writef("Frequency Sub Band:\t%u\r\n", _dot->getFrequencySubBand());
_serial.writef("Public Network:\t\t%s\r\n", _dot->getPublicNetwork() ? "on" : "off");
diff --git a/CommandTerminal/CmdFactoryDefault.cpp b/CommandTerminal/CmdFactoryDefault.cpp
index 955535e..a8554cb 100644
--- a/CommandTerminal/CmdFactoryDefault.cpp
+++ b/CommandTerminal/CmdFactoryDefault.cpp
@@ -29,7 +29,7 @@ uint32_t CmdFactoryDefault::action(std::vector<std::string> args)
_dot->resetConfig();
//Factory defaults for the DotBox.
- _dot->setTxDataRate(mDot::SF_7);
+ _dot->setTxDataRate(mDot::DR0);
_dot->setFrequencySubBand(1);
_dot->setWakeDelay(242); //DotBox +MaxSize is stored here. Default is 242.
_dot->setWakeInterval(11); //DotBox +MinSize is stored here. Default is 11.
diff --git a/CommandTerminal/CmdFrequencyBand.cpp b/CommandTerminal/CmdFrequencyBand.cpp
index 4057f7a..c3116c9 100644
--- a/CommandTerminal/CmdFrequencyBand.cpp
+++ b/CommandTerminal/CmdFrequencyBand.cpp
@@ -19,10 +19,10 @@
#include "CmdFrequencyBand.h"
CmdFrequencyBand::CmdFrequencyBand(mDot* dot, mts::MTSSerial& serial) :
- Command(dot, "Frequency Band", "AT+FREQ", "Configured Frequency Band '868' or '915'"), _serial(serial)
+ Command(dot, "Frequency Band", "AT+FREQ", "Configured Frequency Band 'EU868', 'AU915' or 'US915'"), _serial(serial)
{
_help = std::string(text()) + ": " + std::string(desc());
- _usage = "(868,915)";
+ _usage = "(EU868,AU915,US915)";
_queryable = true;
}
@@ -40,10 +40,22 @@ uint32_t CmdFrequencyBand::action(std::vector<std::string> args)
else if (args.size() == 2)
{
int32_t code;
- uint8_t band = mDot::FB_915;
- if (mDot::FrequencyBandStr(mDot::FB_868).find(args[1]) != std::string::npos) {
- band = mDot::FB_868;
+ std::string text = mts::Text::toUpper(args[1]);
+
+ uint8_t band = mDot::FB_US915;
+
+
+ if (mDot::FrequencyBandStr(mDot::FB_EU868).find(text) != std::string::npos) {
+ band = mDot::FB_EU868;
+ }
+
+ if (mDot::FrequencyBandStr(mDot::FB_AU915).find(text) != std::string::npos) {
+ band = mDot::FB_AU915;
+ }
+
+ if (mDot::FrequencyBandStr(mDot::FB_US915).find(text) != std::string::npos) {
+ band = mDot::FB_US915;
}
if ((code = _dot->setFrequencyBand(band)) != mDot::MDOT_OK) {
@@ -65,10 +77,13 @@ bool CmdFrequencyBand::verify(std::vector<std::string> args)
#ifdef DEBUG_MAC
if (args.size() == 2)
{
- if (mDot::FrequencyBandStr(mDot::FB_868).find(args[1]) == std::string::npos &&
- mDot::FrequencyBandStr(mDot::FB_915).find(args[1]) == std::string::npos)
+ std::string band = mts::Text::toUpper(args[1]);
+
+ if (mDot::FrequencyBandStr(mDot::FB_EU868).find(band) == std::string::npos &&
+ mDot::FrequencyBandStr(mDot::FB_US915).find(band) == std::string::npos &&
+ mDot::FrequencyBandStr(mDot::FB_AU915).find(band) == std::string::npos)
{
- setErrorMessage("Invalid parameter, expects (868,915)");
+ setErrorMessage("Invalid parameter, expects (EU868,AU915,US915)");
return false;
}
diff --git a/CommandTerminal/CmdSendContinuous.cpp b/CommandTerminal/CmdSendContinuous.cpp
new file mode 100644
index 0000000..843d5bf
--- /dev/null
+++ b/CommandTerminal/CmdSendContinuous.cpp
@@ -0,0 +1,13 @@
+#include "CmdSendContinuous.h"
+
+CmdSendContinuous::CmdSendContinuous(mDot* dot)
+: Command(dot, "Send Continuous", "AT+SENDC", "Send un-modulated data continuously") {
+}
+
+uint32_t CmdSendContinuous::action(std::vector<std::string> args) {
+
+ _dot->sendContinuous(true);
+
+ return 0;
+}
+
diff --git a/CommandTerminal/CmdSendContinuous.h b/CommandTerminal/CmdSendContinuous.h
new file mode 100644
index 0000000..403ab54
--- /dev/null
+++ b/CommandTerminal/CmdSendContinuous.h
@@ -0,0 +1,18 @@
+
+#ifndef __CMDSENDCONTINUOUS_H__
+#define __CMDSENDCONTINUOUS_H__
+
+#include "Command.h"
+
+class CmdSendContinuous : public Command {
+
+public:
+
+ CmdSendContinuous(mDot* dot);
+ uint32_t action(std::vector<std::string> args);
+
+private:
+
+};
+
+#endif // __CMDSENDCONTINUOUS_H__
diff --git a/CommandTerminal/CmdTxDataRate.cpp b/CommandTerminal/CmdTxDataRate.cpp
index 846562b..fefbd69 100644
--- a/CommandTerminal/CmdTxDataRate.cpp
+++ b/CommandTerminal/CmdTxDataRate.cpp
@@ -15,49 +15,60 @@
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-
#include "CmdTxDataRate.h"
+#include "MTSText.h"
+#include "MTSLog.h"
-CmdTxDataRate::CmdTxDataRate(mDot* dot, mts::MTSSerial& serial) :
- Command(dot, "Tx Data Rate", "AT+TXDR", "Set the Tx data rate for LoRa demo mode"), _serial(serial)
+CmdTxDataRate::CmdTxDataRate(mDot* dot, mts::MTSSerial& serial)
+:
+ Command(dot, "Tx Data Rate", "AT+TXDR", "Set the Tx data rate for all channels"),
+ _serial(serial)
{
_help = std::string(text()) + ": " + std::string(desc());
- if (_dot->getFrequencyBand() == mDot::FB_915)
- _usage = "(7-10)";
+ if (_dot->getFrequencyBand() == mDot::FB_EU868)
+ _usage = "(7-12|DR0-DR7)";
else
- _usage = "(7-12)";
+ _usage = "(7-10|DR0-DR4|DR8-DR13)";
+
_queryable = true;
}
-uint32_t CmdTxDataRate::action(std::vector<std::string> args)
-{
+uint32_t CmdTxDataRate::action(std::vector<std::string> args) {
if (args.size() == 1)
- {
+ {
if (_dot->getVerbose())
_serial.writef("Tx Data Rate: ");
- _serial.writef("%s\r\n", mDot::DataRateStr(_dot->getTxDataRate()).c_str());
- }
- else if (args.size() == 2)
- {
+ _serial.writef("DR%d - %s\r\n", _dot->getTxDataRate(), _dot->getDateRateDetails(_dot->getTxDataRate()).c_str());
+ } else if (args.size() == 2) {
+ std::string dr = mts::Text::toUpper(args[1]);
int32_t code;
- uint8_t datarate = 0;
+ int datarate = -1;
uint8_t i;
- for (i = 0; i < 8; i++)
- {
- if (mDot::DataRateStr(i).find(args[1].c_str()) != std::string::npos)
- {
- datarate = i;
- break;
+ int res = sscanf(dr.c_str(), "%d", &datarate);
+
+ if (res == 0) {
+ for (i = 0; i < 24; i++) {
+ if (mDot::DataRateStr(i).find(dr) != std::string::npos) {
+ datarate = i;
+ break;
+ }
+ }
+ } else {
+ if (datarate > 6) {
+ // Convert SF to DR
+ if (_dot->getFrequencyBand() == mDot::FB_US915 || _dot->getFrequencyBand() == mDot::FB_AU915 ) {
+ datarate = 10 - datarate;
+ } else {
+ datarate = 12 - datarate;
+ }
}
}
- if ((code = _dot->setTxDataRate(datarate)) != mDot::MDOT_OK)
- {
- std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError();
- setErrorMessage(error);
+ if ((code = _dot->setTxDataRate(datarate)) != mDot::MDOT_OK) {
+ setErrorMessage(_dot->getLastError());
return 1;
}
}
@@ -65,36 +76,69 @@ uint32_t CmdTxDataRate::action(std::vector<std::string> args)
return 0;
}
-bool CmdTxDataRate::verify(std::vector<std::string> args)
-{
+bool CmdTxDataRate::verify(std::vector<std::string> args) {
if (args.size() == 1)
return true;
- if (args.size() == 2)
- {
+ if (args.size() == 2) {
+ std::string dr = mts::Text::toUpper(args[1]);
+
uint8_t i;
int datarate = -1;
- for (i = 0; i < 8; i++)
- {
- if (mDot::DataRateStr(i).find(args[1].c_str()) != std::string::npos)
- {
- datarate = i;
- break;
+
+ int res = sscanf(dr.c_str(), "%d", &datarate);
+
+ if (res == 0) {
+ for (i = 0; i < 24; i++) {
+
+ if (mDot::DataRateStr(i).find(dr) != std::string::npos) {
+ uint8_t _dr = i;
+
+ if (_dr > 15) {
+ _dr = 12 + (mDot::SF_12 - _dr);
+
+ if (_dot->getFrequencyBand() == mDot::FB_EU868) {
+ if (_dr == mDot::SF_7H) {
+ _dr = mDot::DR6;
+ } else if (_dr == mDot::SF_FSK) {
+ _dr = mDot::DR7;
+ } else {
+ _dr = 12 - _dr;
+ }
+ } else {
+
+ _dr = 10 - _dr;
+ }
+ }
+
+ datarate = _dr;
+ break;
+ }
+ }
+ } else {
+ if ((_dot->getFrequencyBand() == mDot::FB_US915 || _dot->getFrequencyBand() == mDot::FB_AU915) && datarate > 10) {
+ datarate = -1;
+ } else if (_dot->getFrequencyBand() == mDot::FB_EU868 && datarate > 12) {
+ datarate = -1;
+ } else if (datarate > 6) {
+ // Convert SF to DR
+ if (_dot->getFrequencyBand() == mDot::FB_US915 || _dot->getFrequencyBand() == mDot::FB_AU915 ) {
+ datarate = 10 - datarate;
+ } else {
+ datarate = 12 - datarate;
+ }
}
}
- if (datarate < 0)
- {
- if (_dot->getFrequencyBand() == mDot::FB_915)
- setErrorMessage("Invalid data rate, expects (7-10)");
- else
- setErrorMessage("Invalid data rate, expects (7-12)");
- return false;
- }
-
- if (_dot->getFrequencyBand() == mDot::FB_915) {
- if (datarate < 2) {
- setErrorMessage("Invalid data rate, expects (7-10)");
+ if (_dot->getFrequencyBand() == mDot::FB_US915 || _dot->getFrequencyBand() == mDot::FB_AU915 ) {
+ // DR8-13 used for P2P modes
+ if (datarate < 0 || datarate > 13 || (datarate >= 5 && datarate <= 7)) {
+ setErrorMessage("Invalid data rate, expects (7-10|DR0-DR4|DR8-DR13)");
+ return false;
+ }
+ } else {
+ if (datarate < 0 || datarate > 7) {
+ setErrorMessage("Invalid data rate, expects (7-12|DR0-DR7)");
return false;
}
}
diff --git a/CommandTerminal/CmdTxFrequency.cpp b/CommandTerminal/CmdTxFrequency.cpp
new file mode 100644
index 0000000..35e7f8d
--- /dev/null
+++ b/CommandTerminal/CmdTxFrequency.cpp
@@ -0,0 +1,26 @@
+#include "CmdTxFrequency.h"
+#include <climits>
+
+
+CmdTxFrequency::CmdTxFrequency(mDot* dot) :
+ Command(dot, "Tx Frequency", "AT+TXF", "Set Tx frequency") {
+}
+
+uint32_t CmdTxFrequency::action(std::vector<std::string> args)
+{
+ if (args.size() == 2)
+ {
+ int frequency = 0;
+
+ sscanf(args[1].c_str(), "%d", &frequency);
+ _dot->setTxFrequency(frequency);
+ }
+
+ return 0;
+}
+
+bool CmdTxFrequency::verify(std::vector<std::string> args)
+{
+ return true;
+}
+
diff --git a/CommandTerminal/CmdTxFrequency.h b/CommandTerminal/CmdTxFrequency.h
new file mode 100644
index 0000000..22eb777
--- /dev/null
+++ b/CommandTerminal/CmdTxFrequency.h
@@ -0,0 +1,20 @@
+#ifndef __CMDTXFREQUENCY_H__
+#define __CMDTXFREQUENCY_H__
+
+#include "Command.h"
+
+class CommandTerminal;
+
+class CmdTxFrequency : public Command {
+
+public:
+
+ CmdTxFrequency(mDot* dot);
+ uint32_t action(std::vector<std::string> args);
+ bool verify(std::vector<std::string> args);
+
+private:
+
+};
+
+#endif // __CMDTXFREQUENCY_H__
diff --git a/CommandTerminal/CmdWriteProtectedConfig.cpp b/CommandTerminal/CmdWriteProtectedConfig.cpp
index 6c2d6ce..db22562 100644
--- a/CommandTerminal/CmdWriteProtectedConfig.cpp
+++ b/CommandTerminal/CmdWriteProtectedConfig.cpp
@@ -24,6 +24,10 @@ CmdWriteProtectedConfig::CmdWriteProtectedConfig(mDot* dot) :
_help = std::string(text()) + ": " + std::string(desc());
}
+CmdWriteProtectedConfig::~CmdWriteProtectedConfig() {
+
+}
+
uint32_t CmdWriteProtectedConfig::action(std::vector<std::string> args)
{
if (!_dot->saveProtectedConfig()) {
diff --git a/CommandTerminal/CmdWriteProtectedConfig.h b/CommandTerminal/CmdWriteProtectedConfig.h
index e5ad3c7..51315fe 100644
--- a/CommandTerminal/CmdWriteProtectedConfig.h
+++ b/CommandTerminal/CmdWriteProtectedConfig.h
@@ -27,6 +27,7 @@ class CmdWriteProtectedConfig : public Command {
public:
CmdWriteProtectedConfig(mDot* dot);
+ virtual ~CmdWriteProtectedConfig();
virtual uint32_t action(std::vector<std::string> args);
private:
diff --git a/CommandTerminal/Commands.h b/CommandTerminal/Commands.h
index 9a06835..b041b19 100644
--- a/CommandTerminal/Commands.h
+++ b/CommandTerminal/Commands.h
@@ -49,4 +49,6 @@
#ifdef MTS_RADIO_DEBUG_COMMANDS
#include "CmdWriteProtectedConfig.h"
+#include "CmdSendContinuous.h"
+#include "CmdTxFrequency.h"
#endif
diff --git a/FileName.h b/FileName.h
index 23468e2..2b671a4 100644
--- a/FileName.h
+++ b/FileName.h
@@ -19,6 +19,6 @@
#ifndef __FILENAME_H__
#define __FILENAME_H__
-extern char* file_name;
+extern char file_name[];
#endif
diff --git a/Layout/LayoutSemtech.cpp b/Layout/LayoutSemtech.cpp
new file mode 100644
index 0000000..e31d149
--- /dev/null
+++ b/Layout/LayoutSemtech.cpp
@@ -0,0 +1,200 @@
+/* Copyright (c) <2016> <MultiTech Systems>, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "LayoutSemtech.h"
+
+
+LayoutSemtech::LayoutSemtech(DOGS102* lcd, uint8_t band)
+ : Layout(lcd),
+ _band(band),
+ _lDr(8,0,"DR"),
+ _lFSB(0,0,"FSB"),
+ _lSend(3,3,"Sending..."),
+ _lTemp(8,6,"Temp "),
+ _lNoGps(0,4,"No Gps Lock"),
+ _lPower(13,0,"P"),
+ _lBlank(0,1," "),
+ _lNoLink(0,1,"Send Failed"),
+ _lPadding(0,6,"Pad"),
+ _lNoChannel(0,3,"No Free Channel"),
+ _fDr(10,0,2),
+ _fSw1(13,7,4),
+ _fSw2(0,7,9),
+ _fFSB(3,0,1),
+ _fTemp(13,6,4),
+ _fPower(14,0,2),
+ _fNextCh(0,5,17),
+ _fGpsLat(0,3,17),
+ _fGpsLon(0,4,17),
+ _fResult(3,3,16),
+ _fGpsTime(0,5,16),
+ _fDownSnr(12,2,5),
+ _fPadding(4,6,3),
+ _fDownRssi(0,2,11)
+{}
+
+LayoutSemtech::~LayoutSemtech() {}
+
+void LayoutSemtech::display() {}
+
+void LayoutSemtech::initial()
+{
+ writeLabel(_lBlank);
+}
+
+void LayoutSemtech::display(bool success, mDot::snr_stats snr, mDot::rssi_stats rssi, int power, int fsb, int padding, int dr)
+{
+ char buf[17];
+ size_t size;
+
+ clear();
+ startUpdate();
+
+ writeLabel(_lDr);
+ writeLabel(_lTemp);
+ writeLabel(_lPower);
+ writeLabel(_lPadding);
+ if (_band == mDot::FB_915) {
+ writeLabel(_lFSB);
+ }
+ if(success) {
+ size = snprintf(buf, sizeof(buf), "DWN %3d dbm", rssi.last);
+ writeField(_fDownRssi, buf, size);
+
+ memset(buf, 0, sizeof(buf));
+ size = snprintf(buf, sizeof(buf), " %2.1f", (float)snr.last / 10.0);
+ writeField(_fDownSnr, buf, size);
+ } else writeLabel(_lNoLink);
+
+ memset(buf, 0, sizeof(buf));
+ size = snprintf(buf, sizeof(buf), "%d",dr);
+ writeField(_fDr, buf, size, true);
+
+ memset(buf, 0, sizeof(buf));
+ size = snprintf(buf, sizeof(buf), "%d",power);
+ writeField(_fPower, buf, size, true);
+
+ if (_band == mDot::FB_915) {
+ memset(buf, 0, sizeof(buf));
+ size = snprintf(buf, sizeof(buf), "%d",fsb);
+ writeField(_fFSB, buf, size, true);
+ }
+
+ memset(buf, 0, sizeof(buf));
+ size = snprintf(buf, sizeof(buf), "%d",padding);
+ writeField(_fPadding, buf, size, true);
+
+ endUpdate();
+}
+
+void LayoutSemtech::updateSw1(string Sw1, string Sw2, int dr, int power, int padding)
+{
+ size_t size;
+ char buf[17];
+ string temp;
+ for(int i = Sw1.size(); i<4; i++) temp+=" ";
+ temp+=Sw1;
+ writeField(_fSw1, temp, true);
+ startUpdate();
+ if(Sw2=="Data Rate") {
+ memset(buf, 0, sizeof(buf));
+ size = snprintf(buf, sizeof(buf), "%d",dr);
+ writeField(_fDr, buf, size, true);
+ } else if(Sw2=="Power") {
+ memset(buf, 0, sizeof(buf));
+ size = snprintf(buf, sizeof(buf), "%d",power);
+ writeField(_fPower, buf, size, true);
+ } else if(Sw2=="Padding") {
+ memset(buf, 0, sizeof(buf));
+ size = snprintf(buf, sizeof(buf), "%d",padding);
+ writeField(_fPadding, buf, size, true);
+ }
+ endUpdate();
+}
+
+void LayoutSemtech::updateSw2(string Sw2)
+{
+ writeField(_fSw2, Sw2, true);
+}
+
+void LayoutSemtech::sending()
+{
+ clear();
+ writeLabel(_lSend);
+}
+
+void LayoutSemtech::sendResult(string str)
+{
+ clear();
+ writeField(_fResult,str,true);
+}
+
+
+void LayoutSemtech::updateNextCh(int count_down)
+{
+ clear();
+ size_t size;
+ char buf[17];
+ size = snprintf(buf, sizeof(buf), "Countdown:%d",count_down);
+ writeField(_fNextCh, buf, size, true);
+ writeLabel(_lNoChannel);
+}
+
+void LayoutSemtech::updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::latitude lat, struct tm time, float temp)
+{
+ char buf[17];
+ size_t size;
+
+ startUpdate();
+
+ if(GPS) {
+ size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c",
+ abs(lon.degrees),
+ lon.minutes,
+ (lon.seconds * 6) / 1000,
+ (lon.seconds * 6) % 1000,
+ (lon.degrees > 0) ? 'E' : 'W');
+ writeField(_fGpsLon, buf, size, true);
+
+ memset(buf, 0, sizeof(buf));
+ size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c",
+ abs(lat.degrees),
+ lat.minutes,
+ (lat.seconds * 6) / 1000,
+ (lat.seconds * 6) % 1000,
+ (lat.degrees > 0) ? 'N' : 'S');
+ writeField(_fGpsLat, buf, size, true);
+
+ memset(buf, 0, sizeof(buf));
+ size = snprintf(buf, sizeof(buf), "%02d:%02d %02d/%02d/%04d",
+ time.tm_hour,
+ time.tm_min,
+ time.tm_mon + 1,
+ time.tm_mday,
+ time.tm_year + 1900);
+ writeField(_fGpsTime, buf, size, true);
+
+ } else writeLabel(_lNoGps);
+
+ memset(buf, 0, sizeof(buf));
+ size = snprintf(buf, sizeof(buf), "%.1f",temp);
+ writeField(_fTemp, buf, size, true);
+
+ endUpdate();
+}
+
diff --git a/Layout/LayoutSemtech.h b/Layout/LayoutSemtech.h
new file mode 100644
index 0000000..dd62fd6
--- /dev/null
+++ b/Layout/LayoutSemtech.h
@@ -0,0 +1,78 @@
+/* Copyright (c) <2016> <MultiTech Systems>, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __LAYOUTSEMTECH_H__
+#define __LAYOUTSEMTECH_H__
+
+#include "Layout.h"
+#include "GPSPARSER.h"
+#include "LoRaHandler.h"
+
+class LayoutSemtech : public Layout
+{
+public:
+ LayoutSemtech(DOGS102* lcd, uint8_t band);
+ ~LayoutSemtech();
+
+ void display();
+ void display(bool success, mDot::snr_stats snr, mDot::rssi_stats rssi,int power, int fsb, int padding, int dr);
+
+ void sending();
+ void initial();
+ void updateSw2(string str);
+ void sendResult(string str);
+ void updateNextCh(int count_down);
+ void updateSw1(string Sw1, string Sw2, int dr, int power, int padding);
+ void updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::latitude lat, struct tm time, float temp);
+
+private:
+ uint8_t _band;
+
+ Label _lDr;
+ Label _lFSB;
+ Label _lSend;
+ Label _lTemp;
+ Label _lNoGps;
+ Label _lPower;
+ Label _lBlank;
+ Label _lNoLink;
+ Label _lPadding;
+ Label _lNoChannel;
+
+ Field _fDr;
+ Field _fSw1;
+ Field _fSw2;
+ Field _fFSB;
+ Field _fTemp;
+ Field _fPower;
+ Field _fNextCh;
+ Field _fGpsLat;
+ Field _fGpsLon;
+ Field _fResult;
+ Field _fGpsTime;
+ Field _fDownSnr;
+ Field _fPadding;
+ Field _fDownRssi;
+};
+
+#endif
+
+
+
+
+
diff --git a/Layout/LayoutSemtechJoin.cpp b/Layout/LayoutSemtechJoin.cpp
new file mode 100644
index 0000000..7bb7ac0
--- /dev/null
+++ b/Layout/LayoutSemtechJoin.cpp
@@ -0,0 +1,91 @@
+/* Copyright (c) <2016> <MultiTech Systems>, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "LayoutSemtechJoin.h"
+
+LayoutSemtechJoin::LayoutSemtechJoin(DOGS102* lcd, uint8_t band)
+ : Layout(lcd),
+ _band(band),
+ _lId(0, 1, "NI="),
+ _lKey(0, 2, "NK="),
+ _lFsb(0, 3, "FSB="),
+ _lRate(0, 5, "DR="),
+ _lPower(6, 5, "P="),
+ _lJoin(0, 7, "Join"),
+ _fId(3, 1, 14),
+ _fKey(3, 2, 14),
+ _fFsb(4, 3, 2),
+ _fRate(3, 5, 2),
+ _fPower(8, 5, 2),
+ _fStatus(0, 0, 17),
+ _fSubBand(16,7,1)
+{}
+
+LayoutSemtechJoin::~LayoutSemtechJoin() {}
+
+void LayoutSemtechJoin::display()
+{
+ clear();
+ startUpdate();
+
+ writeLabel(_lId);
+ writeLabel(_lKey);
+ if (_band == mDot::FB_915) {
+ writeLabel(_lFsb);
+ }
+ writeLabel(_lRate);
+ writeLabel(_lPower);
+ writeLabel(_lJoin);
+
+ endUpdate();
+}
+
+void LayoutSemtechJoin::updateId(std::string id)
+{
+ writeField(_fId, id, true);
+}
+
+void LayoutSemtechJoin::updateKey(std::string key)
+{
+ writeField(_fKey, key, true);
+}
+
+void LayoutSemtechJoin::updateFsb(uint8_t band)
+{
+ if (_band == mDot::FB_915) {
+ char buf[8];
+ size_t size;
+ size = snprintf(buf, sizeof(buf), "%u", band);
+ writeField(_fFsb, buf, size, true);
+ writeField(_fSubBand, buf, size, true);
+ }
+}
+
+void LayoutSemtechJoin::updateRate(std::string rate)
+{
+ writeField(_fRate, rate, true);
+}
+
+void LayoutSemtechJoin::updatePower(uint32_t power)
+{
+ char buf[16];
+ size_t size;
+
+ size = snprintf(buf, sizeof(buf), "%lu", power);
+ writeField(_fPower, buf, size, true);
+}
diff --git a/Layout/LayoutSemtechJoin.h b/Layout/LayoutSemtechJoin.h
new file mode 100644
index 0000000..f848334
--- /dev/null
+++ b/Layout/LayoutSemtechJoin.h
@@ -0,0 +1,59 @@
+/* Copyright (c) <2016> <MultiTech Systems>, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __LAYOUTSEMTECHJOIN_H__
+#define __LAYOUTSEMTECHJOIN_H__
+
+#include "Layout.h"
+#include "mDot.h"
+
+class LayoutSemtechJoin : public Layout {
+ public:
+ LayoutSemtechJoin(DOGS102* lcd, uint8_t band);
+ ~LayoutSemtechJoin();
+
+ void display();
+
+ void updateId(std::string id);
+ void updateKey(std::string key);
+ void updateFsb(uint8_t band);
+ void updateRate(std::string rate);
+ void updatePower(uint32_t power);
+
+ private:
+ uint8_t _band;
+
+ Label _lId;
+ Label _lKey;
+ Label _lFsb;
+ Label _lRate;
+ Label _lPower;
+ Label _lJoin;
+
+ Field _fId;
+ Field _fKey;
+ Field _fFsb;
+ Field _fRate;
+ Field _fPower;
+ Field _fStatus;
+ Field _fSubBand;
+};
+
+#endif
+
+
diff --git a/Mode/Mode.cpp b/Mode/Mode.cpp
index 389bf7f..462e145 100644
--- a/Mode/Mode.cpp
+++ b/Mode/Mode.cpp
@@ -49,7 +49,7 @@ Mode::Mode(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, G
_index(0),
_band(_dot->getFrequencyBand()),
_sub_band(_dot->getFrequencySubBand()),
- _data_rate(mDot::SF_7),
+ _data_rate(mDot::DR0),
_power(2),
_next_tx(0),
_send_data(false),
@@ -129,7 +129,7 @@ bool Mode::appendDataFile(const DataItem& data) {
(data.gps_lock) ? alt_buf : "",
(data.gps_lock) ? time_buf : "",
data.status ? stats_buf : ",,,",
- _dot->DataRateStr(data.data_rate).substr(3).c_str(),
+ _dot->DataRateStr(data.data_rate).substr(2).c_str(),
data.power);
if (size < 0) {
@@ -279,7 +279,7 @@ std::vector<uint8_t> Mode::formatSurveyData(DataItem& data) {
send_data.push_back((data.link.down.snr/10) & 0xFF);
// collect GPS data if GPS device detected
- if (_gps->gpsDetected() && ((_data_rate != mDot::SF_10) || (_band == mDot::FB_868))){
+ if (_gps->gpsDetected() && ((_data_rate != mDot::SF_10) || (_band == mDot::FB_EU868))){
send_data.push_back(0x19); // key for GPS Lock Status
satfix = (_gps->getNumSatellites() << 4 ) | (_gps->getFixStatus() & 0x0F );
send_data.push_back(satfix);
diff --git a/Mode/ModeConfig.cpp b/Mode/ModeConfig.cpp
index 56ba1a0..bd1967d 100644
--- a/Mode/ModeConfig.cpp
+++ b/Mode/ModeConfig.cpp
@@ -75,6 +75,8 @@ ModeConfig::ModeConfig(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHand
#if MTS_RADIO_DEBUG_COMMANDS
addCommand(new CmdWriteProtectedConfig(_dot));
+ addCommand(new CmdSendContinuous(_dot));
+ addCommand(new CmdTxFrequency(_dot));
#endif
}
diff --git a/Mode/ModeDemo.cpp b/Mode/ModeDemo.cpp
index 44732c1..4add135 100644
--- a/Mode/ModeDemo.cpp
+++ b/Mode/ModeDemo.cpp
@@ -41,9 +41,9 @@ bool ModeDemo::start() {
_initial_data_rate = _dot->getTxDataRate();
// use configured data rate and power if possible
- if (_band == mDot::FB_915 && _initial_data_rate == mDot::SF_10) {
- logInfo("using SF_9 instead of SF_10 - SF_10 max packet size is too small for data");
- _dot->setTxDataRate(mDot::SF_9);
+ if (_band == mDot::FB_915 && _initial_data_rate == mDot::DR0) {
+ logInfo("using DR1 instead of DR0 - DR0 max packet size is too small for data");
+ _dot->setTxDataRate(mDot::DR1);
}
_state = show_help;
diff --git a/Mode/ModeGps.cpp b/Mode/ModeGps.cpp
index d97e77e..47053cb 100644
--- a/Mode/ModeGps.cpp
+++ b/Mode/ModeGps.cpp
@@ -55,7 +55,7 @@ void ModeGps::init(){
_help.display();
osDelay(2000);
- if(_band == mDot::FB_868){
+ if(_band == mDot::FB_EU868){
_sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, _data_rate);
_sem.initial();
_state = PARAMETERS;
@@ -86,7 +86,7 @@ void ModeGps::changeDataRate(){
void ModeGps::changeParameter(){
_parameter++;
- if(_band==mDot::FB_868&&_parameter==FSB){
+ if(_band == mDot::FB_EU868 && _parameter == FSB){
_parameter++;
}
if(_parameter>INTERVAL){
@@ -239,7 +239,7 @@ void ModeGps::updateScreen(){
void ModeGps::send(){
_state = SENDING;
_send_timer.stop();
- if(_band==mDot::FB_868) {
+ if(_band == mDot::FB_EU868) {
while(_dot->getNextTxMs()>0) {
_sem.updateNextCh((int)(_dot->getNextTxMs()/1000));
osDelay(250);
diff --git a/Mode/ModeJoin.cpp b/Mode/ModeJoin.cpp
index 239eadb..3a86dd9 100644
--- a/Mode/ModeJoin.cpp
+++ b/Mode/ModeJoin.cpp
@@ -126,4 +126,4 @@ void ModeJoin::display() {
_join.updateRate(_dot->getTxDataRate());
_join.updatePower(_power);
_join.updateAttempt(_lora->getJoinAttempts());
-} \ No newline at end of file
+}
diff --git a/Mode/ModeSemtech.cpp b/Mode/ModeSemtech.cpp
new file mode 100644
index 0000000..5c2d180
--- /dev/null
+++ b/Mode/ModeSemtech.cpp
@@ -0,0 +1,339 @@
+/* Copyright (c) <2016> <MultiTech Systems>, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "ModeSemtech.h"
+#include "MTSLog.h"
+#include "rtos.h"
+#include "mbed.h"
+#include <sstream>
+//this is exactly what it sounds like
+#define TWO_TO_THE_THIRTY_ONE_MINUS_ONE 2147483647
+#define PACKETSIZE 11
+
+
+
+
+ModeSemtech::ModeSemtech(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps, SensorHandler* sensors)
+ : Mode(lcd, buttons, dot, lora, gps, sensors),
+ _help(lcd),
+ _sem(lcd,_band),
+ _sem_join(lcd,_band)
+{}
+
+string ModeSemtech::intToString(int num)
+{
+ return static_cast<ostringstream*>(&(ostringstream() << num))->str();
+}
+
+void ModeSemtech::init()
+{
+ //resets all parameters when re-entering mode
+ _interval = 5;
+ _padding = 0;
+ _power = 20;
+ _band = _dot->getFrequencyBand();
+ _parameter = POWER;
+ _drAll=false;
+ _link_check = false;
+ _GPS = false;
+ _sub_band = _dot->getFrequencySubBand();
+ _data_rate = mDot::DR4;
+ _max_padding = _dot->getMaxPacketLength()-PACKETSIZE;
+ _Sw2 = "Power";
+ _Sw1 = intToString(_power);
+ _help.display();
+ osDelay(2000);
+ if(_band==mDot::FB_EU868){
+ _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, _data_rate);
+ _sem.initial();
+ _state = PARAMETERS;
+ _send_timer.start();
+ }
+ else { _state = BAND_CHANGE;
+ changeBand();
+ }
+}
+
+void ModeSemtech::drIncrement()
+{
+ _data_rate++;
+ if (_data_rate > mDot::DR5) {
+ _drAll = true;
+ _data_rate=0;
+ }
+ _dot->setTxDataRate(_data_rate);
+ logInfo("new data rate %s, POWER %lu", mDot::DataRateStr(_data_rate).c_str(), _power);
+ _max_padding = _dot->getMaxPacketLength()-PACKETSIZE;
+}
+
+void ModeSemtech::changeDataRate()
+{
+ if(_drAll) {
+ if(_band == mDot::FB_EU868) _data_rate = -1;
+ else _data_rate = mDot::DR1;
+ _drAll = false;
+ }
+ drIncrement();
+}
+
+void ModeSemtech::changeParameter()
+{
+ _parameter++;
+ if(_band==mDot::FB_EU868&&_parameter==FSB)_parameter++;
+ if(_parameter>INTERVAL)_parameter=0;
+ switch(_parameter) {
+ case DATA_RATE:
+ _Sw2 = "Data Rate";
+ _Sw1 = intToString(_data_rate);
+ if(_drAll)_Sw1 = "All";
+ break;
+ case FSB:
+ _Sw2 = "FSB";
+ _Sw1 = intToString(_sub_band);
+ break;
+ case PADDING:
+ _Sw2 = "Padding";
+ _Sw1 = intToString(_padding);
+ break;
+ case POWER:
+ _Sw2 = "Power";
+ _Sw1 = intToString(_power);
+ break;
+ case INTERVAL:
+ _Sw2 = "Interval";
+ _Sw1 = intToString(_interval);
+ break;
+ default:
+ break;
+ }
+}
+
+void ModeSemtech::editParameter()
+{
+ switch(_parameter) {
+ case POWER:
+ if(_power<20)_power+=3;
+ else _power = 2;
+ _Sw1 = intToString(_power);
+ _dot->setTxPower(_power);
+ break;
+
+ case DATA_RATE:
+ changeDataRate();
+ _Sw1 = intToString(_data_rate);
+ if(_drAll)_Sw1="All";
+ break;
+
+ case FSB:
+ _send_timer.stop();
+ _send_timer.reset();
+ _state = BAND_CHANGE;
+ _dot->resetNetworkSession();
+ _lora->resetActivityLed();
+ changeBand();
+ break;
+
+ case PADDING:
+ if(_padding<_max_padding)_padding +=10 - (_padding%10);
+ else _padding = 0;
+ if(_padding>_max_padding)_padding = _max_padding;
+ _Sw1 = intToString(_padding);
+ break;
+
+ default:
+ if(_interval<60)_interval += 5;
+ else _interval = 5;
+ _Sw1 = intToString(_interval);
+ break;
+ }
+}
+
+void ModeSemtech::formatData()
+{
+ _send_data.clear();
+ uint32_t lat = 0;
+ uint32_t lng = 0;
+ _temp_C+=0.5;
+
+ if(_GPS) {
+ if(_latitude.degrees<0) lat = ~(int)((_latitude.degrees - ((double)_latitude.minutes/60.0) - ((double)_latitude.seconds/600000.0))*((double)-TWO_TO_THE_THIRTY_ONE_MINUS_ONE/90.0)+1.5);
+ else lat = (int)((_latitude.degrees + ((double)_latitude.minutes/60.0) + ((double)_latitude.seconds/600000.0))*((double)TWO_TO_THE_THIRTY_ONE_MINUS_ONE/90.0)+0.5);
+ if(_longitude.degrees<0) lng = ~(int)((_longitude.degrees - ((double)_longitude.minutes/60.0) - ((double)_longitude.seconds/600000.0))*((double)-TWO_TO_THE_THIRTY_ONE_MINUS_ONE/180.0)+1.5);
+ else lng = (int)((_longitude.degrees + ((double)_longitude.minutes/60.0) + ((double)_longitude.seconds/600000.0))*((double)TWO_TO_THE_THIRTY_ONE_MINUS_ONE/180.0)+0.5);
+ }
+ _send_data.push_back(0);
+ _send_data.push_back((int8_t) _temp_C);
+ _send_data.push_back(0);
+ for(int i=24; i>=0; i-=8)_send_data.push_back((lat>>i)&0xFF);
+ for(int i=24; i>=0; i-=8)_send_data.push_back((lng>>i)&0xFF);
+ for(int i=0; i<(_padding>_max_padding ? _max_padding : _padding); i++) _send_data.push_back(0);
+}
+
+void ModeSemtech::setBand()
+{
+ _sub_band++;
+ if(_sub_band > mDot::FSB_8) _sub_band = mDot::FSB_ALL;
+ _dot->setFrequencySubBand(_sub_band);
+}
+
+void ModeSemtech::changeBand()
+{
+ _sem_join.display();
+ _sem_join.updatePower(_power);
+ _sem_join.updateFsb(_sub_band);
+ _sem_join.updateId(_dot->getNetworkName());
+ _sem_join.updateRate(intToString(_data_rate));
+ _sem_join.updateKey(_dot->getNetworkPassphrase());
+}
+
+void ModeSemtech::updateScreen()
+{
+ _temp_C = _sensors->getTemp(SensorHandler::CELSIUS);
+ if(_gps->getLockStatus()&& _gps_available) {
+ _GPS = true;
+ _latitude = _gps->getLatitude();
+ _longitude = _gps->getLongitude();
+ _time = _gps->getTimestamp();
+ } else _GPS = false;
+ _sem.updateStats( _GPS, _longitude, _latitude, _time, _temp_C);
+ _sem.updateSw1(_Sw1,_Sw2,_data_rate,_power,_padding);
+ _sem.updateSw2(_Sw2);
+}
+
+void ModeSemtech::send()
+{
+ _state = SENDING;
+ _send_timer.stop();
+ if(_band==mDot::FB_EU868) {
+ while(_dot->getNextTxMs()>0) {
+ _sem.updateNextCh((int)(_dot->getNextTxMs()/1000));
+ osDelay(250);
+ }
+ }
+ formatData();
+ _sem.sending();
+ _send_timer.reset();
+ _send_timer.start();
+ _lora->send(_send_data);
+ osDelay(500);
+}
+
+bool ModeSemtech::start()
+{
+ init();
+ _button_timer.start();
+ ButtonHandler::ButtonEvent be;
+ osSignalClear(_main_id, buttonSignal | loraSignal);
+
+ if(_band == mDot::FB_US915 || _band == mDot::FB_AU915)
+ _join = new ModeJoin(_lcd, _buttons, _dot, _lora, _gps, _sensors);
+
+ while (true) {
+ if(_state==PARAMETERS)updateScreen();
+
+ osEvent e = Thread::signal_wait(0, 250);
+ if (e.status == osEventSignal) {
+ if (e.value.signals & buttonSignal) {
+ _button_timer.reset();
+ be = _buttons->getButtonEvent();
+
+ switch(be) {
+ case ButtonHandler::sw1_press:
+ switch(_state) {
+ case BAND_CHANGE:
+ setBand();
+ changeBand();
+ break;
+
+ case SENDING:
+ break;
+
+ case PARAMETERS:
+ editParameter();
+ break;
+ }
+ break;
+ case ButtonHandler::sw2_press:
+ switch(_state) {
+ case BAND_CHANGE:
+ if(_join->start()){
+ _state = PARAMETERS;
+ _send_timer.start();
+ _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, DATA_RATE);
+ _dot->setTxDataRate(_data_rate);
+ } else changeBand();
+ break;
+
+ case SENDING:
+ break;
+
+ case PARAMETERS:
+ changeParameter();
+ break;
+ }
+ break;
+ case ButtonHandler::sw1_hold:
+ _send_timer.stop();
+ _send_timer.reset();
+ return true;
+
+ default:
+ break;
+ }
+
+ }
+ }
+ if (e.value.signals & loraSignal) {
+ _ls = _lora->getStatus();
+ switch (_ls) {
+
+ case LoRaHandler::send_success:
+ _sem.sendResult("Send Sucess!");
+ _link_check = true;
+ _snr = _dot->getSnrStats();
+ _rssi = _dot->getRssiStats();
+ osDelay(500);
+ _button_timer.reset();
+ _state = PARAMETERS;
+ _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, _data_rate);
+ if(_drAll)drIncrement();
+ break;
+
+ case LoRaHandler::send_failure:
+ _sem.sendResult("Send Failed.");
+ _link_check = false;
+ osDelay(500);
+ _button_timer.reset();
+ _state = PARAMETERS;
+ _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, _data_rate);
+ if(_drAll)drIncrement();
+ break;
+
+ default:
+ break;
+ }
+
+ }
+
+ if(_send_timer.read_ms()>_interval*1000&&_button_timer.read_ms()>3000) send();
+
+ }
+}
+
+
+
diff --git a/Mode/ModeSemtech.h b/Mode/ModeSemtech.h
new file mode 100644
index 0000000..4812ec4
--- /dev/null
+++ b/Mode/ModeSemtech.h
@@ -0,0 +1,76 @@
+/* Copyright (c) <2016> <MultiTech Systems>, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __MODESEMTECH_H__
+#define __MODESEMTECH_H__
+
+#include "Mode.h"
+#include "ModeJoin.h"
+#include "LayoutHelp.h"
+#include "LayoutSemtech.h"
+#include "LayoutSemtechJoin.h"
+
+class ModeSemtech : public Mode
+{
+public:
+ ModeSemtech(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps, SensorHandler* sensors);
+ ~ModeSemtech();
+
+ bool start();
+
+private:
+ enum {DATA_RATE, FSB, PADDING, POWER, INTERVAL};
+ enum {BAND_CHANGE, SENDING, PARAMETERS};
+
+ LayoutHelp _help;
+ LayoutSemtech _sem;
+ LayoutSemtechJoin _sem_join;
+
+ ModeJoin* _join;
+
+ Timer _send_timer, _button_timer;
+
+ float _temp_C;
+ std::vector<uint8_t> _send_data;
+ uint8_t _parameter, _padding, _interval,_max_padding, _band;
+ bool _drAll, _link_check, _GPS;
+ string _Sw1, _Sw2;
+
+ struct tm _time;
+ mDot::snr_stats _snr;
+ mDot::rssi_stats _rssi;
+ GPSPARSER::latitude _latitude;
+ GPSPARSER::longitude _longitude;
+
+ void init();
+ void send();
+ void setBand();
+ void sendData();
+ void formatData();
+ void changeBand();
+ void drIncrement();
+ void updateScreen();
+ void editParameter();
+ void changeDataRate();
+ void changeParameter();
+ string intToString(int num);
+
+};
+
+#endif
+
diff --git a/Mode/ModeSingle.cpp b/Mode/ModeSingle.cpp
index 347f636..6cc3f4b 100644
--- a/Mode/ModeSingle.cpp
+++ b/Mode/ModeSingle.cpp
@@ -176,8 +176,8 @@ bool ModeSingle::start() {
_state = failure;
_failure.display();
_failure.updateId(_index);
- // mDot::DataRateStr returns format SF_XX - we only want to display the XX part
- _failure.updateRate(_dot->DataRateStr(_data_rate).substr(3));
+ // mDot::DataRateStr returns format DRXX - we only want to display the XX part
+ _failure.updateRate(_dot->DataRateStr(_data_rate).substr(2));
updateData(_data, single, false);
appendDataFile(_data);
_failure.updatePower(_power);
@@ -291,7 +291,7 @@ void ModeSingle::displaySuccess() {
_success.display();
_success.updateId(_index);
// mDot::DataRateStr returns format SF_XX - we only want to display the XX part
- _success.updateRate(_dot->DataRateStr(_data_rate).substr(3));
+ _success.updateRate(_dot->DataRateStr(_data_rate).substr(2));
_success.updatePower(_power);
_success.updateStats(_link_check_result);
if (_gps_available && _gps->getLockStatus()) {
@@ -312,7 +312,7 @@ std::string ModeSingle::formatRatePower() {
size_t size;
msg += "DR=";
- msg += _dot->DataRateStr(_data_rate).substr(3);
+ msg += _dot->DataRateStr(_data_rate).substr(2);
msg += " P=";
size = snprintf(buf, sizeof(buf), "%u", _power);
msg.append(buf, size);
@@ -323,28 +323,11 @@ std::string ModeSingle::formatRatePower() {
void ModeSingle::incrementRatePower() {
if (_power == 20) {
_power = 2;
- switch (_data_rate) {
- case mDot::SF_7:
- _data_rate = mDot::SF_8;
- break;
- case mDot::SF_8:
- _data_rate = mDot::SF_9;
- break;
- case mDot::SF_9:
- _data_rate = mDot::SF_10;
- break;
- case mDot::SF_10:
- if (_band == mDot::FB_915)
- _data_rate = mDot::SF_7;
- else
- _data_rate = mDot::SF_11;
- break;
- case mDot::SF_11:
- _data_rate = mDot::SF_12;
- break;
- case mDot::SF_12:
- _data_rate = mDot::SF_7;
- break;
+ _data_rate++;
+ if ((_band == mDot::FB_US915 && _data_rate > mDot::DR4) ||
+ (_band == mDot::FB_AU915 && _data_rate > mDot::DR4) ||
+ (_band == mDot::FB_EU868 && _data_rate > mDot::DR7)) {
+ _data_rate = mDot::DR0;
}
} else {
_power += 3;
diff --git a/Mode/ModeSweep.cpp b/Mode/ModeSweep.cpp
index 6ff4e34..b6bef24 100644
--- a/Mode/ModeSweep.cpp
+++ b/Mode/ModeSweep.cpp
@@ -207,8 +207,7 @@ bool ModeSweep::start() {
_state = failure;
_failure.display();
_failure.updateId(_index);
- // mDot::DataRateStr returns format SF_XX - we only want to display the XX part
- _failure.updateRate(_dot->DataRateStr(_data_rate).substr(3));
+ _failure.updateRate(_dot->DataRateStr(_data_rate).substr(2));
_failure.updatePower(_power);
if (_gps_available && _gps->getLockStatus()) {
GPSPARSER::latitude lat = _gps->getLatitude();
@@ -343,8 +342,7 @@ void ModeSweep::displayHelp() {
void ModeSweep::displaySuccess() {
_success.display();
_success.updateId(_index);
- // mDot::DataRateStr returns format SF_XX - we only want to display the XX part
- _success.updateRate(_dot->DataRateStr(_data_rate).substr(3));
+ _success.updateRate(_dot->DataRateStr(_data_rate).substr(2));
_success.updatePower(_power);
_success.updateStats(_link_check_result);
if (_gps_available && _gps->getLockStatus()) {
@@ -383,23 +381,21 @@ std::vector<point> ModeSweep::generatePoints() {
uint8_t ModeSweep::payloadToRate(uint8_t payload) {
if (_band == mDot::FB_915) {
- if (payload <= mDot::MaxLengths_915[mDot::SF_10])
- return mDot::SF_10;
- else if (payload <= mDot::MaxLengths_915[mDot::SF_9])
- return mDot::SF_9;
- else if (payload <= mDot::MaxLengths_915[mDot::SF_8])
- return mDot::SF_8;
+ if (payload <= mDot::MaxLengths_915[mDot::DR0])
+ return mDot::DR0;
+ else if (payload <= mDot::MaxLengths_915[mDot::DR1])
+ return mDot::DR1;
+ else if (payload <= mDot::MaxLengths_915[mDot::DR2])
+ return mDot::DR2;
else
- return mDot::SF_7;
+ return mDot::DR4;
} else {
- if (payload <= mDot::MaxLengths_868[mDot::SF_12])
- return mDot::SF_12;
- else if (payload <= mDot::MaxLengths_868[mDot::SF_9])
- return mDot::SF_9;
+ if (payload <= mDot::MaxLengths_868[mDot::DR0])
+ return mDot::DR0;
+ else if (payload <= mDot::MaxLengths_868[mDot::DR3])
+ return mDot::DR3;
else
- return mDot::SF_7;
+ return mDot::DR6;
}
-
- return mDot::SF_7;
}
diff --git a/main.cpp b/main.cpp
index f1276f6..71ac376 100644
--- a/main.cpp
+++ b/main.cpp
@@ -47,6 +47,9 @@
#include "FileName.h"
#include <string>
+#define DISABLE_DUTY_CYCLE true
+
+
// LCD and LED controllers
SPI lcd_spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK);
I2C led_i2c(I2C_SDA, I2C_SCL);
@@ -63,6 +66,7 @@ ButtonHandler* buttons;
// LoRa controller
LoRaHandler* lora_handler;
+
mDot* dot;
// GPS
@@ -85,14 +89,13 @@ ModeData* modeData;
Serial debug(USBTX, USBRX);
// Survey Data File
-char* file_name;
+char file_name[] = "SurveyData.txt";
// Prototypes
void mainMenu();
int main() {
debug.baud(115200);
- file_name = "SurveyData.txt";
lcd = new DOGS102(lcd_spi, lcd_spi_cs, lcd_cd);
// NCP5623B::LEDs 1 & 2 are the screen backlight - not used on default build
@@ -103,6 +106,14 @@ int main() {
buttons = new ButtonHandler(main_id);
dot = mDot::getInstance();
lora_handler = new LoRaHandler(main_id);
+
+ dot->setDisableDutyCycle(DISABLE_DUTY_CYCLE);
+ dot->setLinkCheckThreshold(0);
+ dot->setLinkCheckCount(0);
+
+ // Seed the RNG
+ srand(dot->getRadioRandom());
+
gps = new GPSPARSER(&gps_serial, led_cont);
sensors = new SensorHandler();
@@ -118,6 +129,7 @@ int main() {
modeGps = new ModeGps(lcd, buttons, dot, lora_handler, gps, sensors, modeJoin);
modeData = new ModeData(lcd, buttons, dot, lora_handler, gps, sensors);
+
osDelay(1000);
logInfo("%sGPS detected", gps->gpsDetected() ? "" : "no ");
@@ -145,6 +157,7 @@ void mainMenu() {
sweep,
gps,
data
+
} menu_items;
std::string menu_strings[] = {
@@ -153,8 +166,8 @@ void mainMenu() {
"Configuration",
"Survey Single",
"Survey Sweep",
- "Survey Gps",
- "Survey Data"
+ "Survey GPS",
+ "View Data"
};
std::vector<std::string> items;
items.push_back(menu_strings[demo]);
@@ -171,6 +184,7 @@ void mainMenu() {
// reset session between modes
dot->resetNetworkSession();
lora_handler->resetActivityLed();
+
LayoutScrollSelect menu(lcd, items, product, menu_strings[0]);
menu.display();
@@ -205,8 +219,10 @@ void mainMenu() {
if (modeJoin->start())
modeSweep->start();
} else if (selected == menu_strings[gps]) {
- if(dot->getFrequencyBand()==mDot::FB_868)modeJoin->start();
- modeGps->start();
+ if(dot->getFrequencyBand() == mDot::FB_EU868) {
+ modeJoin->start();
+ }
+ modeGps->start();
} else if (selected == menu_strings[data]) {
modeData->start();
}
@@ -215,3 +231,5 @@ void mainMenu() {
}
}
+
+
diff --git a/mdot-library b/mdot-library
-Subproject bbbe3a131a661e979dc9ee122f43d9cd082b3e5
+Subproject f3b5de8c7106bfd15ce9dc33bbe3f189319178d
diff --git a/parser_function.txt b/parser_function.txt
index 06a7a60..4bc16f9 100644
--- a/parser_function.txt
+++ b/parser_function.txt
@@ -182,7 +182,7 @@ while (msg_pntr < msg.payload.length){
}
}
-pData.sf_val = parseInt(msg.datr.replace("SF"," "),10);
+pData.sf_val = parseInt(msg.datr.replace("DR"," "),10);
context.global.data_out = pData;