Custom "Installer Assistant" software. Modified Single Sweep Mode. Goes right into single sweep mode upon power-up and displays signal strength. Works with mbed-os 5.1.2 and mdot lib 5.1.5
Dependencies: DOGS102 GpsParser ISL29011 MMA845x MPL3115A2 MTS-Serial NCP5623B libmDot-dev-mbed5-deprecated
Fork of MTDOT-BOX-EVB-Factory-Firmware by
Revision 7:a31236c2e75c, committed 2016-11-04
- Comitter:
- Mike Fiore
- Date:
- Fri Nov 04 17:27:05 2016 -0500
- Parent:
- 6:cc61867b45ce
- Child:
- 8:ddc66fd44c8d
- Commit message:
- update from git revision 2.1.2
Changed in this revision
--- a/CommandTerminal/CmdDisplayConfig.cpp Fri Nov 04 22:21:01 2016 +0000
+++ b/CommandTerminal/CmdDisplayConfig.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -17,7 +17,7 @@
*/
#include "CmdDisplayConfig.h"
-#include "version.h"
+#include "dotbox_version.h"
#include "MTSLog.h"
std::string version = MTDOT_BOX_VERSION;
@@ -38,7 +38,7 @@
_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");
--- a/CommandTerminal/CmdFactoryDefault.cpp Fri Nov 04 22:21:01 2016 +0000
+++ b/CommandTerminal/CmdFactoryDefault.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -29,7 +29,7 @@
_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.
--- a/CommandTerminal/CmdFrequencyBand.cpp Fri Nov 04 22:21:01 2016 +0000
+++ b/CommandTerminal/CmdFrequencyBand.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -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 @@
else if (args.size() == 2)
{
int32_t code;
- uint8_t band = mDot::FB_915;
+
+ std::string text = mts::Text::toUpper(args[1]);
+
+ uint8_t band = mDot::FB_US915;
+
- if (mDot::FrequencyBandStr(mDot::FB_868).find(args[1]) != std::string::npos) {
- band = mDot::FB_868;
+ 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 @@
#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;
}
--- a/CommandTerminal/CmdIdentification.cpp Fri Nov 04 22:21:01 2016 +0000
+++ b/CommandTerminal/CmdIdentification.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -17,7 +17,7 @@
*/
#include "CmdIdentification.h"
-#include "version.h"
+#include "dotbox_version.h"
CmdIdentification::CmdIdentification(mDot* dot, mts::MTSSerial& serial) : Command(dot, "Request Id", "ATI", "Request Identification"), _serial(serial)
{
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CommandTerminal/CmdSendContinuous.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -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;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CommandTerminal/CmdSendContinuous.h Fri Nov 04 17:27:05 2016 -0500
@@ -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__
--- a/CommandTerminal/CmdTxDataRate.cpp Fri Nov 04 22:21:01 2016 +0000
+++ b/CommandTerminal/CmdTxDataRate.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -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 @@
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;
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CommandTerminal/CmdTxFrequency.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -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;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CommandTerminal/CmdTxFrequency.h Fri Nov 04 17:27:05 2016 -0500
@@ -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__
--- a/CommandTerminal/CmdWriteProtectedConfig.cpp Fri Nov 04 22:21:01 2016 +0000
+++ b/CommandTerminal/CmdWriteProtectedConfig.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -24,6 +24,10 @@
_help = std::string(text()) + ": " + std::string(desc());
}
+CmdWriteProtectedConfig::~CmdWriteProtectedConfig() {
+
+}
+
uint32_t CmdWriteProtectedConfig::action(std::vector<std::string> args)
{
if (!_dot->saveProtectedConfig()) {
--- a/CommandTerminal/CmdWriteProtectedConfig.h Fri Nov 04 22:21:01 2016 +0000
+++ b/CommandTerminal/CmdWriteProtectedConfig.h Fri Nov 04 17:27:05 2016 -0500
@@ -27,6 +27,7 @@
public:
CmdWriteProtectedConfig(mDot* dot);
+ virtual ~CmdWriteProtectedConfig();
virtual uint32_t action(std::vector<std::string> args);
private:
--- a/CommandTerminal/Commands.h Fri Nov 04 22:21:01 2016 +0000 +++ b/CommandTerminal/Commands.h Fri Nov 04 17:27:05 2016 -0500 @@ -49,4 +49,6 @@ #ifdef MTS_RADIO_DEBUG_COMMANDS #include "CmdWriteProtectedConfig.h" +#include "CmdSendContinuous.h" +#include "CmdTxFrequency.h" #endif
--- a/FileName.h Fri Nov 04 22:21:01 2016 +0000 +++ b/FileName.h Fri Nov 04 17:27:05 2016 -0500 @@ -19,6 +19,6 @@ #ifndef __FILENAME_H__ #define __FILENAME_H__ -extern char* file_name; +extern char file_name[]; #endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Layout/LayoutData.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -0,0 +1,104 @@
+/* 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 "LayoutData.h"
+
+LayoutData::LayoutData(DOGS102* lcd)
+ : Layout(lcd),
+ _lDr(8, 0, "DR"),
+ _lPwr(13, 0, "P"),
+ _lUp(0, 1, "UP Mgn"),
+ _lGw(10, 1, "Gw"),
+ _lDown(0, 2, "DWN -"),
+ _lSurveyFailed(0, 1, "Survey Failed"),
+ _lDbm(9, 2, "dbm"),
+ _lAlt(0, 6, "Alt"),
+ _fId(0, 0, 5),
+ _fDr(10, 0, 2),
+ _fPwr(14, 0, 2),
+ _fUpMargin(7, 1, 2),
+ _fGw(13, 1, 2),
+ _fRssiDown(5, 2, 3),
+ _fSnrDown(13, 2, 4),
+ _fGpsLat(0, 4, 17),
+ _fGpsLong(0, 3, 17),
+ _fGpsTime(0, 5, 17),
+ _fAlt(4,6,13),
+ _fSw1(12, 7, 4),
+ _fSw2(0, 7, 4)
+{}
+
+LayoutData::~LayoutData() {}
+
+void LayoutData::display(){
+ clear();
+ startUpdate();
+ writeLabel(_lDr);
+ writeLabel(_lPwr);
+ endUpdate();
+}
+
+void LayoutData::noData(){
+ clear();
+ writeField(_fGpsLong, string(" No Survey Data"), true);
+}
+
+void LayoutData::errorData(){
+ clear();
+ writeField(_fGpsLong, string(" Error opening,"), true);
+ writeField(_fGpsLat, string("survey data file."), true);
+}
+
+void LayoutData::updateSw1(string str){
+ writeField(_fSw1, str, true);
+}
+
+void LayoutData::updateSw2(string str){
+ writeField(_fSw2, str, true);
+}
+
+bool LayoutData::updateAll(singleLine& line){
+ clear();
+ startUpdate();
+ //this data should always exist
+ writeLabel(_lDr);
+ writeLabel(_lPwr);
+ writeField(_fId, line.id, true);
+ writeField(_fDr, line.dataRate, true);
+ writeField(_fPwr, line.power, true);
+ //check if survey pass/fail
+ if(line.status=="S") {
+ writeLabel(_lUp);
+ writeLabel(_lDown);
+ writeLabel(_lGw);
+ writeLabel(_lDbm);
+ writeField(_fGw, line.gateways, true);
+ writeField(_fUpMargin, line.margin, true);
+ writeField(_fRssiDown, line.rssiD, true);
+ writeField(_fSnrDown, line.snrD, true);
+ } else writeLabel(_lSurveyFailed);
+ //check if gps data exists
+ if(line.lock!="0") {
+ writeLabel(_lAlt);
+ writeField(_fGpsLat, line.lat, true);
+ writeField(_fGpsLong, line.lng, true);
+ writeField(_fGpsTime, line.time, true);
+ writeField(_fAlt, line.alt + " m", true);
+ } else writeField(_fGpsLong, string("No GPS Data"), true);
+ endUpdate();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Layout/LayoutData.h Fri Nov 04 17:27:05 2016 -0500
@@ -0,0 +1,77 @@
+/* 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 __LAYOUTDATA_H__
+#define __LAYOUTDATA_H__
+
+#include "Layout.h"
+
+class LayoutData : public Layout{
+public:
+ LayoutData(DOGS102* lcd);
+ ~LayoutData();
+
+ struct singleLine {
+ string id,
+ status,
+ lock,
+ lat,
+ lng,
+ alt,
+ time,
+ gateways,
+ margin,
+ rssiD,
+ snrD,
+ dataRate,
+ power;
+ } ;
+
+ void display();
+ void noData();
+ void noGps();
+ void errorData();
+ void updateSw1(string str);
+ void updateSw2(string str);
+ bool updateAll(singleLine& line);
+
+private:
+ Label _lDr;
+ Label _lPwr;
+ Label _lUp;
+ Label _lGw;
+ Label _lDown;
+ Label _lDbm;
+ Label _lSurveyFailed;
+ Label _lAlt;
+
+ Field _fId;
+ Field _fDr;
+ Field _fPwr;
+ Field _fUpMargin;
+ Field _fRssiDown;
+ Field _fSnrDown;
+ Field _fGpsLat;
+ Field _fGpsLong;
+ Field _fGpsTime;
+ Field _fGw;
+ Field _fAlt;
+ Field _fSw1;
+ Field _fSw2;
+};
+#endif
--- a/Layout/LayoutJoin.cpp Fri Nov 04 22:21:01 2016 +0000
+++ b/Layout/LayoutJoin.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -1,4 +1,4 @@
-/* Copyright (c) <2016> <MultiTech Systems>, MIT License
+/* /* 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,
@@ -47,7 +47,7 @@
writeLabel(_lId);
writeLabel(_lKey);
- if (_band == mDot::FB_915) {
+ if (_band == mDot::FB_US915 || _band == mDot::FB_AU915) {
writeLabel(_lFsb);
}
writeLabel(_lRate);
@@ -75,8 +75,12 @@
writeField(_fFsb, buf, size, true);
}
-void LayoutJoin::updateRate(std::string rate) {
- writeField(_fRate, rate, true);
+void LayoutJoin::updateRate(uint8_t rate) {
+ char buf[8];
+ size_t size;
+
+ size = snprintf(buf, sizeof(buf), "%u", rate);
+ writeField(_fRate, buf, size, true);
}
void LayoutJoin::updatePower(uint32_t power) {
@@ -119,3 +123,31 @@
writeField(_fCancel, str, true);
}
+void LayoutJoin::updateJoinFsb(uint8_t band) {
+ char buf[8];
+ size_t size;
+
+ size = snprintf(buf, sizeof(buf), "%u", band);
+ writeField(_fFsb, buf, size, true);
+ size = snprintf(buf, sizeof(buf), " %u", band);
+ writeField(_fCancel, buf, size, true);
+}
+
+void LayoutJoin::displayEditFsb(uint8_t rate, uint32_t power, uint8_t band, string key, string id){
+ clear();
+ startUpdate();
+
+ writeLabel(_lId);
+ writeLabel(_lKey);
+ writeLabel(_lFsb);
+ writeLabel(_lRate);
+ writeLabel(_lPower);
+ writeField(_fCountdown, string("Join"), true);
+ updateId(id);
+ updateKey(key);
+ updateJoinFsb(band);
+ updateRate(rate);
+ updatePower(power);
+
+ endUpdate();
+}
--- a/Layout/LayoutJoin.h Fri Nov 04 22:21:01 2016 +0000
+++ b/Layout/LayoutJoin.h Fri Nov 04 17:27:05 2016 -0500
@@ -28,11 +28,13 @@
~LayoutJoin();
void display();
+ void displayEditFsb(uint8_t rate, uint32_t power, uint8_t band, string key, string id);
void updateId(std::string id);
void updateKey(std::string key);
void updateFsb(uint8_t band);
- void updateRate(std::string rate);
+ void updateJoinFsb(uint8_t band);
+ void updateRate(uint8_t rate);
void updatePower(uint32_t power);
void updateAttempt(uint32_t attempt);
void updateStatus(std::string status);
@@ -59,5 +61,4 @@
Field _fCancel;
uint8_t _band;
};
-
#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Layout/LayoutSemtech.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -0,0 +1,204 @@
+/* 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_US915 || _band == mDot::FB_AU915) {
+ 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_US915 || _band == mDot::FB_AU915) {
+ 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();
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Layout/LayoutSemtech.h Fri Nov 04 17:27:05 2016 -0500
@@ -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
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Layout/LayoutSemtechJoin.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -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_US915 || _band == mDot::FB_AU915) {
+ 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_US915 || _band == mDot::FB_AU915) {
+ 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);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Layout/LayoutSemtechJoin.h Fri Nov 04 17:27:05 2016 -0500
@@ -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
+
+
--- a/Layout/LayoutStartup.cpp Fri Nov 04 22:21:01 2016 +0000
+++ b/Layout/LayoutStartup.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -18,16 +18,16 @@
#include "LayoutStartup.h"
#include "MultiTech_Logo.h"
-#include "version.h"
+#include "dotbox_version.h"
#include "MTSText.h"
LayoutStartup::LayoutStartup(DOGS102* lcd, mDot* dot)
: Layout(lcd),
_dot(dot),
- _lName(0, 3, "MTDOT-BOX/EVB"),
+ _lName(0, 3, "DOT-BOX/EVB"),
_lInfo(0, 4, "Factory Firmware"),
_lVersion(0, 5, "Version"),
- _fName(14, 3, 3),
+ _fName(12, 3, 5),
_fVersion(8, 5, 9),
_fId(0, 7, 17),
_fGps(0, 6, 17),
@@ -47,7 +47,7 @@
writeLabel(_lName);
writeLabel(_lInfo);
writeLabel(_lVersion);
- writeField(_fName, mDot::FrequencyBandStr(_dot->getFrequencyBand()).substr(3));
+ writeField(_fName, mDot::FrequencyBandStr(_dot->getFrequencyBand()));
writeField(_fVersion, version);
writeField(_fId, id);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Layout/LayoutSurveyGps.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -0,0 +1,166 @@
+/* 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 "LayoutSurveyGps.h"
+LayoutSurveyGps::LayoutSurveyGps(DOGS102* lcd, uint8_t band)
+ : Layout(lcd),
+ _band(band),
+ _lDR(8,0,"DR"),
+ _lFSB(0,0,"FSB"),
+ _lTemp(8,6,"Temp "),
+ _lPower(13,0,"P"),
+ _lPadding(0,6,"Pad"),
+ _fDr(10,0,2),
+ _fSw1(13,7,4),
+ _fSw2(0,7,9),
+ _fFSB(3,0,1),
+ _fTemp(13,6,4),
+ _fPower(14,0,2),
+ _fNoLink(0,1,17),
+ _fGpsLat(0,3,17),
+ _fGpsLon(0,4,17),
+ _fGpsTime(0,5,17),
+ _fDownSnr(12,2,5),
+ _fPadding(4,6,3),
+ _fDownRssi(0,2,12)
+{}
+
+LayoutSurveyGps::~LayoutSurveyGps() {}
+
+void LayoutSurveyGps::display() {}
+
+void LayoutSurveyGps::initial(){
+ writeField(_fNoLink, string(" "), true);
+}
+
+void LayoutSurveyGps::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_US915 || _band == mDot::FB_AU915) {
+ 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", snr.last / 10.0);
+ writeField(_fDownSnr, buf, size);
+ } else {
+ writeField(_fNoLink,string("Send Failed"),true);
+ }
+
+ 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_US915 || _band == mDot::FB_AU915) {
+ 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 LayoutSurveyGps::updateSw1(string Sw1, string Sw2){
+ string temp;
+ for(int i = Sw1.size(); i<4; i++){
+ temp+=" ";
+ }
+ temp+=Sw1;
+ writeField(_fSw1, temp, true);
+}
+
+void LayoutSurveyGps::updateSw2(string Sw2){
+ writeField(_fSw2, Sw2, true);
+}
+
+void LayoutSurveyGps::sending(){
+ clear();
+ writeField(_fGpsLat,string(" Sending..."),true);
+}
+
+void LayoutSurveyGps::sendResult(string str){
+ clear();
+ writeField(_fGpsLat,str,true);
+}
+
+void LayoutSurveyGps::updateNextCh(int count_down){
+ clear();
+ size_t size;
+ char buf[17];
+ size = snprintf(buf, sizeof(buf), "Countdown:%d", count_down);
+ writeField(_fGpsTime, buf, size, true);
+ writeField(_fGpsLon, string("No Free Channel"), true);
+}
+
+void LayoutSurveyGps::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 {
+ writeField(_fGpsLon, string("No Gps Lock"), true);
+ }
+ memset(buf, 0, sizeof(buf));
+ size = snprintf(buf, sizeof(buf), "%.1f", temp);
+ writeField(_fTemp, buf, size, true);
+ endUpdate();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Layout/LayoutSurveyGps.h Fri Nov 04 17:27:05 2016 -0500
@@ -0,0 +1,65 @@
+/* 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 __LAYOUTSURVEYGPS_H__
+#define __LAYOUTSURVEYGPS_H__
+
+#include "Layout.h"
+#include "GPSPARSER.h"
+#include "mDot.h"
+
+class LayoutSurveyGps : public Layout{
+public:
+ LayoutSurveyGps(DOGS102* lcd, uint8_t band);
+ ~LayoutSurveyGps();
+
+ 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);
+ void updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::latitude lat, struct tm time, float temp);
+
+private:
+ uint8_t _band;
+
+ Label _lDR;
+ Label _lFSB;
+ Label _lTemp;
+ Label _lPower;
+ Label _lPadding;
+
+ Field _fDr;
+ Field _fSw1;
+ Field _fSw2;
+ Field _fFSB;
+ Field _fTemp;
+ Field _fPower;
+ Field _fNoLink;
+ Field _fGpsLat;
+ Field _fGpsLon;
+ Field _fGpsTime;
+ Field _fDownSnr;
+ Field _fPadding;
+ Field _fDownRssi;
+};
+#endif
--- a/LoRaHandler/LoRaHandler.cpp Fri Nov 04 22:21:01 2016 +0000
+++ b/LoRaHandler/LoRaHandler.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -87,12 +87,16 @@
l->_mutex.unlock();
if (ret == mDot::MDOT_OK) {
l->_status = LoRaHandler::join_success;
+ osSignalSet(l->_main, loraSignal);
+ l->_tick.detach();
+ l->_activity_led = LoRaHandler::green;
} else {
l->_status = LoRaHandler::join_failure;
+ osSignalSet(l->_main, loraSignal);
+ l->_tick.detach();
+ l->_activity_led = LoRaHandler::red;
}
- osSignalSet(l->_main, loraSignal);
- l->_tick.detach();
- l->_activity_led = LoRaHandler::green;
+
break;
default:
@@ -180,3 +184,4 @@
_activity_led = red;
}
+
--- a/Mode/Mode.cpp Fri Nov 04 22:21:01 2016 +0000
+++ b/Mode/Mode.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -49,7 +49,7 @@
_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 @@
(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 @@
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);
--- a/Mode/ModeConfig.cpp Fri Nov 04 22:21:01 2016 +0000
+++ b/Mode/ModeConfig.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -75,6 +75,8 @@
#if MTS_RADIO_DEBUG_COMMANDS
addCommand(new CmdWriteProtectedConfig(_dot));
+ addCommand(new CmdSendContinuous(_dot));
+ addCommand(new CmdTxFrequency(_dot));
#endif
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mode/ModeData.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -0,0 +1,187 @@
+/* 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 "ModeData.h"
+#include "MTSText.h"
+#define ONELINEMAX 93
+
+ModeData::ModeData(DOGS102* lcd, ButtonHandler* _buttons, mDot* _dot, LoRaHandler* lora, GPSPARSER* gps, SensorHandler* sensors)
+ :Mode(lcd,_buttons,_dot,lora,gps,sensors),
+ _data(lcd),
+ _help(lcd),
+ _buf_size(ONELINEMAX)
+{}
+
+ModeData::~ModeData() {}
+
+bool ModeData::checkFile(){
+ bool exists = false;
+ //get all files and see if file exists
+ vector<mDot::mdot_file> files = _dot->listUserFiles();
+ for (vector<mDot::mdot_file>::iterator it = files.begin(); it != files.end(); it++) {
+ if (strcmp(file_name,it->name)==0) {
+ exists = true;
+ break;
+ }
+ }
+ //if file doesnt exist exit to main menu
+ if(!exists) {
+ _data.noData();
+ osDelay(3000);
+ return true;
+ }
+ _file = _dot->openUserFile(file_name, mDot::FM_RDONLY);
+ //if nothing is in file exit to main menu
+ if (_file.fd < 0) {
+ _data.errorData();
+ osDelay(3000);
+ _dot->closeUserFile(_file);
+ return true;
+ }
+ return false;
+}
+
+bool ModeData::start(){
+ if(checkFile())
+ return true;
+ _help.display();
+ osDelay(3000);
+ readFile();
+}
+
+void ModeData::displayData(){
+ std::vector<std::string> data = mts::Text::split(_str, ',');
+ _line.id = data.at(0);
+ _line.status = data.at(1);
+ _line.lock = data.at(2);
+ _line.lat = data.at(3);
+ _line.lng = data.at(4);
+ _line.alt = data.at(5);
+ _line.time = data.at(6);
+ _line.gateways = data.at(7);
+ _line.margin = data.at(8);
+ _line.rssiD = data.at(9);
+ _line.snrD = data.at(10);
+ _line.dataRate = data.at(11);
+ _line.power = data.at(12);
+ _data.updateAll(_line);
+}
+
+//get the current line out of the buffer into str
+void ModeData::getLine(){
+ _prev = 0;
+ _indexUpdate = 0;
+ _str = "";
+ _dot->readUserFile(_file, (void*)_buf, _buf_size);
+ //only gets called when going back
+ if(_last) {
+ //-3 puts it back to one before new line
+ _indexUpdate = _buf_size - 3;
+ //check from back of buffer for new line
+ while(_buf[_indexUpdate] != '\n' && _indexUpdate >= 0){
+ _indexUpdate--;
+ }
+ _indexUpdate++;
+ }
+ //go from indexUpdate to new line to ge the line
+ //prev keeps track of how long line read was
+ while(_buf[_indexUpdate]!='\n') {
+ _str += _buf[_indexUpdate];
+ _indexUpdate++;
+ _prev++;
+ }
+ //push index past newline
+ _index += _indexUpdate + 1;
+ displayData();
+}
+
+void ModeData::back(){
+ if(_index >= (_buf_size + _prev)) {
+ _index -= (_prev + _buf_size);
+ } else {
+ //special case for beginning of file
+ if(_index > 0){
+ _buf_size = _index-1;
+ }
+ _buf_size -= _prev;
+ _index = 0;
+ }
+ _last = true;
+ _dot->seekUserFile(_file, _index, SEEK_SET);
+ getLine();
+}
+
+void ModeData::forward(){
+ _last = false;
+ if(_index < _file.size) {
+ _buf_size = ONELINEMAX;
+ _dot->seekUserFile(_file, _index, SEEK_SET);
+ getLine();
+ }
+}
+
+//update switch labels
+void ModeData::configSw(){
+ if(_index - (_prev+1) <= 0){
+ _data.updateSw2("");
+ } else {
+ _data.updateSw2("Back");
+ }
+ if(_index<_file.size){
+ _data.updateSw1("Next");
+ } else {
+ _data.updateSw1("");
+ }
+}
+
+bool ModeData::readFile(){
+ _index = 0;
+ _last = false;
+ _prev = 0;
+ _indexUpdate = 0;
+ //called to start on page one
+ forward();
+ configSw();
+ ButtonHandler::ButtonEvent be;
+ while (true) {
+ be = _buttons->getButtonEvent();
+ switch(be) {
+ case ButtonHandler::sw1_press:
+ if(_index!=_file.size) {
+ forward();
+ configSw();
+ }
+ break;
+
+ case ButtonHandler::sw2_press:
+ if(_index - (_prev+1) > 0) {
+ back();
+ configSw();
+ }
+ break;
+
+ case ButtonHandler::sw1_hold:
+ _dot->closeUserFile(_file);
+ return true;
+
+ default:
+ break;
+ }
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mode/ModeData.h Fri Nov 04 17:27:05 2016 -0500
@@ -0,0 +1,58 @@
+/* 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 __MODEDATA_H__
+#define __MODEDATA_H__
+
+#include "Mode.h"
+#include "LayoutData.h"
+#include "LayoutHelp.h"
+
+class ModeData : public Mode{
+
+public:
+ ModeData(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps, SensorHandler* sensors);
+ ~ModeData();
+
+ bool start();
+
+private:
+ bool _last;
+ string _str;
+
+ int32_t _pos, _buf_size, _indexUpdate, _prev;
+ uint32_t _index;
+
+ char _buf[93];
+
+ mDot::mdot_file _file;
+
+ LayoutData _data;
+ LayoutHelp _help;
+ LayoutData::singleLine _line;
+
+ bool checkFile();
+ bool readFile();
+ string parse();
+ void getLine();
+ void displayData();
+ void forward();
+ void back();
+ void configSw();
+};
+#endif
\ No newline at end of file
--- a/Mode/ModeDemo.cpp Fri Nov 04 22:21:01 2016 +0000
+++ b/Mode/ModeDemo.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -41,9 +41,14 @@
_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_US915 || _band == mDot::FB_AU915) && (_initial_data_rate == mDot::DR0 || _initial_data_rate == mDot::SF_10)) {
+ if(_initial_data_rate == mDot::DR0){
+ logInfo("using DR1 instead of DR0 - DR0 max packet size is too small for data");
+ _dot->setTxDataRate(mDot::DR1);
+ }else{
+ logInfo("using SF_9 instead of SF_10 - SF_10 max packet size is too small for data");
+ _dot->setTxDataRate(mDot::SF_9);
+ }
}
_state = show_help;
@@ -103,8 +108,9 @@
case ButtonHandler::sw1_hold:
_send_timer.stop();
_send_timer.reset();
- if (_band == mDot::FB_915)
+ if (_band == mDot::FB_US915 || _band == mDot::FB_AU915) {
_dot->setTxDataRate(_initial_data_rate);
+ }
return true;
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mode/ModeGps.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -0,0 +1,356 @@
+/* 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 "ModeGps.h"
+#include "MTSLog.h"
+#include "rtos.h"
+#include "mbed.h"
+#include "limits.h"
+#define PACKETSIZE 11
+
+ModeGps::ModeGps(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps, SensorHandler* sensors, ModeJoin* join)
+ : Mode(lcd, buttons, dot, lora, gps, sensors),
+ _help(lcd),
+ _sem(lcd, _band),
+ _sem_join(lcd, _band),
+ _join(join)
+{}
+
+string ModeGps::intToString(int num){
+ char buf[3];
+ snprintf(buf, sizeof(buf), "%d", num);
+ return buf;
+}
+
+void ModeGps::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::DR0;
+ _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;
+ _sem_join.displayEditFsb(_data_rate, _power, _sub_band, _dot->getNetworkName(), _dot->getNetworkPassphrase());
+ }
+}
+
+void ModeGps::drIncrement(){
+ _data_rate++;
+ if ((_data_rate > mDot::DR4 && (_band == mDot::FB_US915 || _band == mDot::FB_AU915)) || _data_rate > mDot::DR6) {
+ _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 ModeGps::changeDataRate(){
+ if(_drAll) {
+ _data_rate = -1;
+ _drAll = false;
+ }
+ drIncrement();
+}
+
+void ModeGps::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 ModeGps::editParameter(){
+ switch(_parameter) {
+ case POWER:
+ if(_power<20){
+ _power+=3;
+ } else {
+ _power = 2;
+ }
+ _Sw1 = intToString(_power);
+ _dot->setTxPower(_power);
+ break;
+
+ case DATA_RATE:
+ changeDataRate();
+ if(_drAll) {
+ _Sw1="All";
+ } else {
+ _Sw1 = intToString(_data_rate);
+ }
+ break;
+
+ case FSB:
+ _send_timer.stop();
+ _send_timer.reset();
+ _state = BAND_CHANGE;
+ _dot->resetNetworkSession();
+ _lora->resetActivityLed();
+ _sem_join.displayEditFsb(mDot::DR0, 20, _sub_band, _dot->getNetworkName(), _dot->getNetworkPassphrase());
+ 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 ModeGps::formatData(){
+ _send_data.clear();
+ uint32_t lat = 0;
+ uint32_t lng = 0;
+ double degrees = 0;
+ double minutes = 0;
+ double seconds = 0;
+ _temp_C += 0.5;
+
+ if(_GPS) {
+ degrees = _latitude.degrees;
+ minutes = _latitude.minutes;
+ seconds = _latitude.seconds;
+ if(degrees<0) {
+ lat = ~(int)((degrees - minutes/60.0 - seconds/600000.0)*(-INT_MAX/90.0 + 1.5));
+ } else {
+ lat = (int)((degrees + minutes/60.0 + seconds/600000.0)*(INT_MAX/90.0 + 0.5));
+ }
+ degrees = _longitude.degrees;
+ minutes = _longitude.minutes;
+ seconds = _longitude.seconds;
+ if(degrees<0) {
+ lng = ~(int)((degrees - minutes/60.0 - seconds/600000.0)*(-INT_MAX/180.0 + 1.5));
+ } else {
+ lng = (int)((degrees + minutes/60.0 + seconds/600000.0)*(INT_MAX/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 ModeGps::setBand(){
+ _sub_band++;
+ if(_sub_band > mDot::FSB_8) _sub_band = mDot::FSB_ALL;
+ _dot->setFrequencySubBand(_sub_band);
+}
+
+void ModeGps::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);
+ _sem.updateSw2(_Sw2);
+}
+
+void ModeGps::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 ModeGps::start(){
+ init();
+ _button_timer.start();
+ ButtonHandler::ButtonEvent be;
+ osSignalClear(_main_id, buttonSignal | loraSignal);
+ 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();
+ _sem_join.updateJoinFsb(_sub_band);
+ break;
+
+ case PARAMETERS:
+ editParameter();
+ break;
+
+ default:
+ 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);
+ _sem.initial();
+ _dot->setTxDataRate(_data_rate);
+ } else _sem_join.displayEditFsb(mDot::DR0, 20, _sub_band, _dot->getNetworkName(), _dot->getNetworkPassphrase());
+ break;
+
+ case PARAMETERS:
+ changeParameter();
+ break;
+
+ default:
+ 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!");
+ osDelay(500);
+ _link_check = true;
+ _snr = _dot->getSnrStats();
+ _rssi = _dot->getRssiStats();
+ _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.");
+ osDelay(500);
+ _link_check = false;
+ _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();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mode/ModeGps.h Fri Nov 04 17:27:05 2016 -0500
@@ -0,0 +1,77 @@
+/* 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 __MODEGPS_H__
+#define __MODEGPS_H__
+
+#include "Mode.h"
+#include "ModeJoin.h"
+#include "LayoutHelp.h"
+#include "LayoutSurveyGps.h"
+
+class ModeGps : public Mode{
+public:
+ ModeGps(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps, SensorHandler* sensors, ModeJoin* join);
+ ~ModeGps();
+ bool start();
+
+private:
+ enum {DATA_RATE,
+ FSB,
+ PADDING,
+ POWER,
+ INTERVAL
+ };
+ enum {BAND_CHANGE,
+ SENDING,
+ PARAMETERS
+ };
+
+ LayoutHelp _help;
+ LayoutSurveyGps _sem;
+ LayoutJoin _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;
+ 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 drIncrement();
+ void updateScreen();
+ void editParameter();
+ void changeDataRate();
+ void changeParameter();
+ string intToString(int num);
+};
+#endif
\ No newline at end of file
--- a/Mode/ModeJoin.cpp Fri Nov 04 22:21:01 2016 +0000
+++ b/Mode/ModeJoin.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -42,7 +42,7 @@
_initial_data_rate = _dot->getTxDataRate();
_initial_power = _dot->getTxPower();
- _data_rate = (_band == mDot::FB_915) ? mDot::SF_10 : mDot::SF_12;
+ _data_rate = mDot::DR0;
_power = 20;
_joined = false;
@@ -119,13 +119,11 @@
_join.updateId(_dot->getNetworkName());
_join.updateKey(_dot->getNetworkPassphrase());
}
- if (_band == mDot::FB_915) {
+ if (_band == mDot::FB_US915 || _band == mDot::FB_AU915) {
_sub_band = _dot->getFrequencySubBand();
_join.updateFsb(_sub_band);
}
- // mDot::DataRateStr returns format SF_XX - we only want to display the XX part
- _join.updateRate(_dot->DataRateStr(_data_rate).substr(3));
+ _join.updateRate(_dot->getTxDataRate());
_join.updatePower(_power);
_join.updateAttempt(_lora->getJoinAttempts());
}
-
--- a/Mode/ModeSingle.cpp Fri Nov 04 22:21:01 2016 +0000
+++ b/Mode/ModeSingle.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -176,8 +176,8 @@
_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 @@
_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 @@
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 @@
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::DR6)) {
+ _data_rate = mDot::DR0;
}
} else {
_power += 3;
--- a/Mode/ModeSweep.cpp Fri Nov 04 22:21:01 2016 +0000
+++ b/Mode/ModeSweep.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -207,8 +207,7 @@
_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();
@@ -262,7 +261,7 @@
}
// wait 5s in EU mode to compensate for potential "no free channel" situations on server
- if ((_band == mDot::FB_915 && _display_timer.read_ms() > 2000) || _display_timer.read_ms() > 5000) {
+ if ((_band != mDot::FB_EU868 && _display_timer.read_ms() > 2000) || _display_timer.read_ms() > 5000) {
_display_timer.stop();
_display_timer.reset();
if (_survey_current == _survey_total) {
@@ -343,8 +342,7 @@
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()) {
@@ -382,24 +380,22 @@
}
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 (_band == mDot::FB_EU868) {
+ 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;
} 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_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;
}
-
- return mDot::SF_7;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dotbox_version.h Fri Nov 04 17:27:05 2016 -0500 @@ -0,0 +1,6 @@ +#ifndef __VERSION_H__ +#define __VERSION_H__ + +#define MTDOT_BOX_VERSION "2.1.1-95-g81cf0b0" + +#endif
--- a/main.cpp Fri Nov 04 22:21:01 2016 +0000
+++ b/main.cpp Fri Nov 04 17:27:05 2016 -0500
@@ -41,10 +41,15 @@
#include "ModeSweep.h"
#include "ModeDemo.h"
#include "ModeConfig.h"
+#include "ModeGps.h"
+#include "ModeData.h"
// misc heders
#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);
@@ -60,7 +65,8 @@
ButtonHandler* buttons;
// LoRa controller
-LoRaHandler* lora;
+LoRaHandler* lora_handler;
+
mDot* dot;
// GPS
@@ -76,19 +82,20 @@
ModeSweep* modeSweep;
ModeDemo* modeDemo;
ModeConfig* modeConfig;
+ModeGps* modeGps;
+ModeData* modeData;
// Serial debug port
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
@@ -98,7 +105,15 @@
main_id = Thread::gettid();
buttons = new ButtonHandler(main_id);
dot = mDot::getInstance();
- lora = new LoRaHandler(main_id);
+ 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();
@@ -106,11 +121,14 @@
MTSLog::setLogLevel(MTSLog::TRACE_LEVEL);
- modeJoin = new ModeJoin(lcd, buttons, dot, lora, gps, sensors);
- modeSingle = new ModeSingle(lcd, buttons, dot, lora, gps, sensors);
- modeSweep = new ModeSweep(lcd, buttons, dot, lora, gps, sensors);
- modeDemo = new ModeDemo(lcd, buttons, dot, lora, gps, sensors);
- modeConfig = new ModeConfig(lcd, buttons, dot, lora, gps, sensors);
+ modeJoin = new ModeJoin(lcd, buttons, dot, lora_handler, gps, sensors);
+ modeSingle = new ModeSingle(lcd, buttons, dot, lora_handler, gps, sensors);
+ modeSweep = new ModeSweep(lcd, buttons, dot, lora_handler, gps, sensors);
+ modeDemo = new ModeDemo(lcd, buttons, dot, lora_handler, gps, sensors);
+ modeConfig = new ModeConfig(lcd, buttons, dot, lora_handler, gps, sensors);
+ 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 ");
@@ -136,7 +154,10 @@
demo = 1,
config,
single,
- sweep
+ sweep,
+ gps,
+ data
+
} menu_items;
std::string menu_strings[] = {
@@ -144,22 +165,26 @@
"LoRa Demo",
"Configuration",
"Survey Single",
- "Survey Sweep"
+ "Survey Sweep",
+ "Survey GPS",
+ "View Data"
};
-
std::vector<std::string> items;
items.push_back(menu_strings[demo]);
items.push_back(menu_strings[config]);
items.push_back(menu_strings[single]);
items.push_back(menu_strings[sweep]);
+ items.push_back(menu_strings[gps]);
+ items.push_back(menu_strings[data]);
while (true) {
- product = "MTDOT-BOX/EVB ";
- product += mDot::FrequencyBandStr(dot->getFrequencyBand()).substr(3);
+ product = "DOT-BOX/EVB ";
+ product += mDot::FrequencyBandStr(dot->getFrequencyBand());
// reset session between modes
dot->resetNetworkSession();
- lora->resetActivityLed();
+ lora_handler->resetActivityLed();
+
LayoutScrollSelect menu(lcd, items, product, menu_strings[0]);
menu.display();
@@ -182,7 +207,6 @@
}
}
}
-
if (selected == menu_strings[demo]) {
if (modeJoin->start())
modeDemo->start();
@@ -194,9 +218,18 @@
} else if (selected == menu_strings[sweep]) {
if (modeJoin->start())
modeSweep->start();
- }
+ } else if (selected == menu_strings[gps]) {
+ if(dot->getFrequencyBand() == mDot::FB_EU868) {
+ modeJoin->start();
+ }
+ modeGps->start();
+ } else if (selected == menu_strings[data]) {
+ modeData->start();
+ }
mode_selected = false;
}
}
+
+
--- a/version.h Fri Nov 04 22:21:01 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -#ifndef __VERSION_H__ -#define __VERSION_H__ - -#define MTDOT_BOX_VERSION "2.1.1" - -#endif
