summaryrefslogtreecommitdiff
path: root/CommandTerminal
diff options
context:
space:
mode:
authorLeon Lindenfelser <llindenfelser@multitech.com>2015-11-16 16:18:09 -0600
committerLeon Lindenfelser <llindenfelser@multitech.com>2015-11-16 16:18:09 -0600
commitf484beed77531d7ef2da65cf049fe9c4ac6b7d08 (patch)
tree4b7c15b9ec44819e1e1488b020f164143241d88e /CommandTerminal
parente6bfab044122be837c2235a6bf634b369c753e9c (diff)
downloadmtdot-box-evb-factory-firmware-f484beed77531d7ef2da65cf049fe9c4ac6b7d08.tar.gz
mtdot-box-evb-factory-firmware-f484beed77531d7ef2da65cf049fe9c4ac6b7d08.tar.bz2
mtdot-box-evb-factory-firmware-f484beed77531d7ef2da65cf049fe9c4ac6b7d08.zip
Added all the new dotbox commands with some detail work still needed
Diffstat (limited to 'CommandTerminal')
-rw-r--r--CommandTerminal/CmdData.cpp55
-rw-r--r--CommandTerminal/CmdData.h21
-rw-r--r--CommandTerminal/CmdDeleteSurveyDataFile.cpp21
-rw-r--r--CommandTerminal/CmdDeleteSurveyDataFile.h20
-rw-r--r--CommandTerminal/CmdExit.cpp19
-rw-r--r--CommandTerminal/CmdExit.h20
-rw-r--r--CommandTerminal/CmdGetSurveyDataFile.cpp19
-rw-r--r--CommandTerminal/CmdGetSurveyDataFile.h20
-rw-r--r--CommandTerminal/CmdMaximumPower.cpp62
-rw-r--r--CommandTerminal/CmdMaximumPower.h21
-rw-r--r--CommandTerminal/CmdMaximumSize.cpp62
-rw-r--r--CommandTerminal/CmdMaximumSize.h21
-rw-r--r--CommandTerminal/CmdMinimumPower.cpp62
-rw-r--r--CommandTerminal/CmdMinimumPower.h21
-rw-r--r--CommandTerminal/CmdMinimumSize.cpp62
-rw-r--r--CommandTerminal/CmdMinimumSize.h21
-rw-r--r--CommandTerminal/CommandTerminal.cpp10
-rw-r--r--CommandTerminal/Commands.h9
18 files changed, 546 insertions, 0 deletions
diff --git a/CommandTerminal/CmdData.cpp b/CommandTerminal/CmdData.cpp
new file mode 100644
index 0000000..339fc4b
--- /dev/null
+++ b/CommandTerminal/CmdData.cpp
@@ -0,0 +1,55 @@
+#include "CmdData.h"
+
+CmdData::CmdData(mDot* dot, mts::MTSSerial& serial) :
+ Command(dot, "Data", "AT+DATA", "Enable/disable sending survey data results packet to the network server upon each successful survey. (0: off, 1: on)"), _serial(serial)
+{
+ _help = std::string(text()) + ": " + std::string(desc());
+ _usage = "(0,1)";
+ _queryable = true;
+}
+
+uint32_t CmdData::action(std::vector<std::string> args)
+{
+ if (args.size() == 1)
+ {
+ if (_dot->getVerbose())
+ _serial.writef("%s: ", name());
+//ToDo: Change from _dot->getPublicNetwork() to the structure we will use for this.
+ _serial.writef("%d\r\n", _dot->getPublicNetwork());
+ }
+ else if (args.size() == 2)
+ {
+ int32_t code;
+ bool enable = (args[1] == "1");
+
+ if ((code = _dot->setPublicNetwork(enable)) != mDot::MDOT_OK) {
+ std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError();
+ setErrorMessage(error);
+ return 1;
+ }
+ }
+
+ return 0;
+
+}
+
+bool CmdData::verify(std::vector<std::string> args)
+{
+ if (args.size() == 1)
+ return true;
+
+ if (args.size() == 2)
+ {
+ if (args[1] != "1" && args[1] != "0") {
+ setErrorMessage("Invalid parameter, expects (0: off, 1: on)");
+ return false;
+ }
+
+ return true;
+ }
+
+ setErrorMessage("Invalid arguments");
+ return false;
+
+}
+
diff --git a/CommandTerminal/CmdData.h b/CommandTerminal/CmdData.h
new file mode 100644
index 0000000..ac2a874
--- /dev/null
+++ b/CommandTerminal/CmdData.h
@@ -0,0 +1,21 @@
+#ifndef __CMDDATA_H__
+#define __CMDDATA_H__
+
+#include "Command.h"
+
+class CommandTerminal;
+
+class CmdData: public Command
+{
+
+public:
+
+ CmdData(mDot* dot, mts::MTSSerial& serial);
+ virtual uint32_t action(std::vector<std::string> args);
+ virtual bool verify(std::vector<std::string> args);
+
+private:
+ mts::MTSSerial& _serial;
+};
+
+#endif // __CMDDATA_H__
diff --git a/CommandTerminal/CmdDeleteSurveyDataFile.cpp b/CommandTerminal/CmdDeleteSurveyDataFile.cpp
new file mode 100644
index 0000000..d6eca22
--- /dev/null
+++ b/CommandTerminal/CmdDeleteSurveyDataFile.cpp
@@ -0,0 +1,21 @@
+#include "CmdDeleteSurveyDataFile.h"
+
+CmdDeleteSurveyDataFile::CmdDeleteSurveyDataFile(mDot* dot, mts::MTSSerial& serial) :
+ Command(dot, "Delete Survey Data File", "AT+DSDF", "Delete the survey data file"), _serial(serial)
+{
+ _help = std::string(text()) + ": " + std::string(desc());
+}
+
+uint32_t CmdDeleteSurveyDataFile::action(std::vector<std::string> args)
+{
+//ToDo: Delete the file.
+ if (!_dot->saveConfig()) {
+ setErrorMessage("Failed to save to flash");
+ return 1;
+ }
+
+ return 0;
+
+}
+
+
diff --git a/CommandTerminal/CmdDeleteSurveyDataFile.h b/CommandTerminal/CmdDeleteSurveyDataFile.h
new file mode 100644
index 0000000..a0e1663
--- /dev/null
+++ b/CommandTerminal/CmdDeleteSurveyDataFile.h
@@ -0,0 +1,20 @@
+#ifndef __CMDDELETESURVEYDATAFILE_H__
+#define __CMDDELETESURVEYDATAFILE_H__
+
+#include "Command.h"
+
+class CommandTerminal;
+
+class CmdDeleteSurveyDataFile: public Command
+{
+
+public:
+
+ CmdDeleteSurveyDataFile(mDot* dot, mts::MTSSerial& serial);
+ virtual uint32_t action(std::vector<std::string> args);
+
+private:
+ mts::MTSSerial& _serial;
+};
+
+#endif // __CMDDELETESURVEYDATAFILE_H__
diff --git a/CommandTerminal/CmdExit.cpp b/CommandTerminal/CmdExit.cpp
new file mode 100644
index 0000000..46923b3
--- /dev/null
+++ b/CommandTerminal/CmdExit.cpp
@@ -0,0 +1,19 @@
+#include "CmdExit.h"
+
+CmdExit::CmdExit(mDot* dot, mts::MTSSerial& serial) :
+ Command(dot, "Exit", "AT+EXIT", "Exit from command mode to main menu"), _serial(serial)
+{
+ _help = std::string(text()) + ": " + std::string(desc());
+}
+
+uint32_t CmdExit::action(std::vector<std::string> args)
+{
+//ToDo: Probably setting or clearing a flag to indicate to some other task to shut down command mode and display the main menu.
+ if (!_dot->saveConfig()) {
+ setErrorMessage("Failed to save to flash");
+ return 1;
+ }
+
+ return 0;
+
+}
diff --git a/CommandTerminal/CmdExit.h b/CommandTerminal/CmdExit.h
new file mode 100644
index 0000000..20231db
--- /dev/null
+++ b/CommandTerminal/CmdExit.h
@@ -0,0 +1,20 @@
+#ifndef __CMDEXIT_H__
+#define __CMDEXIT_H__
+
+#include "Command.h"
+
+class CommandTerminal;
+
+class CmdExit: public Command
+{
+
+public:
+
+ CmdExit(mDot* dot, mts::MTSSerial& serial);
+ virtual uint32_t action(std::vector<std::string> args);
+
+private:
+ mts::MTSSerial& _serial;
+};
+
+#endif // __CMDEXIT_H__
diff --git a/CommandTerminal/CmdGetSurveyDataFile.cpp b/CommandTerminal/CmdGetSurveyDataFile.cpp
new file mode 100644
index 0000000..11d9ae3
--- /dev/null
+++ b/CommandTerminal/CmdGetSurveyDataFile.cpp
@@ -0,0 +1,19 @@
+#include "CmdGetSurveyDataFile.h"
+
+CmdGetSurveyDataFile::CmdGetSurveyDataFile(mDot* dot, mts::MTSSerial& serial) :
+ Command(dot, "Get Survey Data File", "AT+GSDF", "Outputs the survey data file to the command port"), _serial(serial)
+{
+ _help = std::string(text()) + ": " + std::string(desc());
+}
+
+uint32_t CmdGetSurveyDataFile::action(std::vector<std::string> args)
+{
+//ToDo: Output the file contents line by line.
+ if (!_dot->saveConfig()) {
+ setErrorMessage("Failed to save to flash");
+ return 1;
+ }
+
+ return 0;
+
+}
diff --git a/CommandTerminal/CmdGetSurveyDataFile.h b/CommandTerminal/CmdGetSurveyDataFile.h
new file mode 100644
index 0000000..ff4cf57
--- /dev/null
+++ b/CommandTerminal/CmdGetSurveyDataFile.h
@@ -0,0 +1,20 @@
+#ifndef __CMDGETSURVEYDATAFILE_H__
+#define __CMDGETSURVEYDATAFILE_H__
+
+#include "Command.h"
+
+class CommandTerminal;
+
+class CmdGetSurveyDataFile: public Command
+{
+
+public:
+
+ CmdGetSurveyDataFile(mDot* dot, mts::MTSSerial& serial);
+ virtual uint32_t action(std::vector<std::string> args);
+
+private:
+ mts::MTSSerial& _serial;
+};
+
+#endif // __CMDGETSURVEYDATAFILE_H__
diff --git a/CommandTerminal/CmdMaximumPower.cpp b/CommandTerminal/CmdMaximumPower.cpp
new file mode 100644
index 0000000..832fbfb
--- /dev/null
+++ b/CommandTerminal/CmdMaximumPower.cpp
@@ -0,0 +1,62 @@
+#include "CmdMaximumPower.h"
+
+CmdMaximumPower::CmdMaximumPower(mDot* dot, mts::MTSSerial& serial) :
+ Command(dot, "Maximum Power", "AT+MAXPWR", "Set the maximum transmit power for sweep survey mode"), _serial(serial)
+{
+ _help = std::string(text()) + ": " + std::string(desc());
+ _usage = "(2-20)";
+ _queryable = true;
+}
+
+uint32_t CmdMaximumPower::action(std::vector<std::string> args)
+{
+ if (args.size() == 1)
+ {
+ if (_dot->getVerbose())
+ _serial.writef("Maximum Power: ");
+//ToDo: Change from _dot->getTxPower() to the structure we will use for this.
+ _serial.writef("%lu\r\n", _dot->getTxPower());
+ }
+ else if (args.size() == 2)
+ {
+ int32_t code;
+ uint32_t power = 0;
+ sscanf(args[1].c_str(), "%lu", &power);
+
+ if ((code = _dot->setTxPower(power)) != mDot::MDOT_OK)
+ {
+ std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError();
+ setErrorMessage(error);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+bool CmdMaximumPower::verify(std::vector<std::string> args)
+{
+ if (args.size() == 1)
+ return true;
+
+ if (args.size() == 2)
+ {
+ uint32_t power = 0;
+ if (sscanf(args[1].c_str(), "%lu", &power) != 1) {
+ setErrorMessage("Invalid argument");
+ return false;
+ }
+
+ if (power < 2 || power > 20)
+ {
+ setErrorMessage("Invalid maximum transmit power for sweep survey mode, expects (2-20)");
+ return false;
+ }
+//ToDo: Output warning if < minimum size.
+ return true;
+ }
+
+ setErrorMessage("Invalid arguments");
+ return false;
+}
+
diff --git a/CommandTerminal/CmdMaximumPower.h b/CommandTerminal/CmdMaximumPower.h
new file mode 100644
index 0000000..f5d3bca
--- /dev/null
+++ b/CommandTerminal/CmdMaximumPower.h
@@ -0,0 +1,21 @@
+#ifndef __CMDMAXIMUMPOWER_H__
+#define __CMDMAXIMUMPOWER_H__
+
+#include "Command.h"
+
+class CommandTerminal;
+
+class CmdMaximumPower: public Command
+{
+
+public:
+
+ CmdMaximumPower(mDot* dot, mts::MTSSerial& serial);
+ virtual uint32_t action(std::vector<std::string> args);
+ virtual bool verify(std::vector<std::string> args);
+
+private:
+ mts::MTSSerial& _serial;
+};
+
+#endif // __CMDMAXIMUMPOWER_H__
diff --git a/CommandTerminal/CmdMaximumSize.cpp b/CommandTerminal/CmdMaximumSize.cpp
new file mode 100644
index 0000000..b8be63b
--- /dev/null
+++ b/CommandTerminal/CmdMaximumSize.cpp
@@ -0,0 +1,62 @@
+#include "CmdMaximumSize.h"
+
+CmdMaximumSize::CmdMaximumSize(mDot* dot, mts::MTSSerial& serial) :
+ Command(dot, "Maximum Size", "AT+MAXSIZE", "Set the maximum payload size for sweep survey mode"), _serial(serial)
+{
+ _help = std::string(text()) + ": " + std::string(desc());
+ _usage = "(11-242)";
+ _queryable = true;
+}
+
+uint32_t CmdMaximumSize::action(std::vector<std::string> args)
+{
+ if (args.size() == 1)
+ {
+ if (_dot->getVerbose())
+ _serial.writef("Maximum Size: ");
+//ToDo: Change from _dot->getTxPower() to the structure we will use for this.
+ _serial.writef("%lu\r\n", _dot->getTxPower());
+ }
+ else if (args.size() == 2)
+ {
+ int32_t code;
+ uint32_t power = 0;
+ sscanf(args[1].c_str(), "%lu", &power);
+
+ if ((code = _dot->setTxPower(power)) != mDot::MDOT_OK)
+ {
+ std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError();
+ setErrorMessage(error);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+bool CmdMaximumSize::verify(std::vector<std::string> args)
+{
+ if (args.size() == 1)
+ return true;
+
+ if (args.size() == 2)
+ {
+ uint32_t power = 0;
+ if (sscanf(args[1].c_str(), "%lu", &power) != 1) {
+ setErrorMessage("Invalid argument");
+ return false;
+ }
+
+ if (power < 11 || power > 242)
+ {
+ setErrorMessage("Invalid maximum payload size, expects (11-242)");
+ return false;
+ }
+//ToDo: Output warning if < minimum size.
+ return true;
+ }
+
+ setErrorMessage("Invalid arguments");
+ return false;
+}
+
diff --git a/CommandTerminal/CmdMaximumSize.h b/CommandTerminal/CmdMaximumSize.h
new file mode 100644
index 0000000..4a7e416
--- /dev/null
+++ b/CommandTerminal/CmdMaximumSize.h
@@ -0,0 +1,21 @@
+#ifndef __CMDMAXIMUMSIZE_H__
+#define __CMDMAXIMUMSIZE_H__
+
+#include "Command.h"
+
+class CommandTerminal;
+
+class CmdMaximumSize: public Command
+{
+
+public:
+
+ CmdMaximumSize(mDot* dot, mts::MTSSerial& serial);
+ virtual uint32_t action(std::vector<std::string> args);
+ virtual bool verify(std::vector<std::string> args);
+
+private:
+ mts::MTSSerial& _serial;
+};
+
+#endif // __CMDMAXIMUMSIZE_H__
diff --git a/CommandTerminal/CmdMinimumPower.cpp b/CommandTerminal/CmdMinimumPower.cpp
new file mode 100644
index 0000000..96aa28e
--- /dev/null
+++ b/CommandTerminal/CmdMinimumPower.cpp
@@ -0,0 +1,62 @@
+#include "CmdMinimumPower.h"
+
+CmdMinimumPower::CmdMinimumPower(mDot* dot, mts::MTSSerial& serial) :
+ Command(dot, "Minimum Power", "AT+MINPWR", "Set the minimum transmit power for sweep survey mode"), _serial(serial)
+{
+ _help = std::string(text()) + ": " + std::string(desc());
+ _usage = "(2-20)";
+ _queryable = true;
+}
+
+uint32_t CmdMinimumPower::action(std::vector<std::string> args)
+{
+ if (args.size() == 1)
+ {
+ if (_dot->getVerbose())
+ _serial.writef("Minimum Power: ");
+//ToDo: Change from _dot->getTxPower() to the structure we will use for this.
+ _serial.writef("%lu\r\n", _dot->getTxPower());
+ }
+ else if (args.size() == 2)
+ {
+ int32_t code;
+ uint32_t power = 0;
+ sscanf(args[1].c_str(), "%lu", &power);
+
+ if ((code = _dot->setTxPower(power)) != mDot::MDOT_OK)
+ {
+ std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError();
+ setErrorMessage(error);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+bool CmdMinimumPower::verify(std::vector<std::string> args)
+{
+ if (args.size() == 1)
+ return true;
+
+ if (args.size() == 2)
+ {
+ uint32_t power = 0;
+ if (sscanf(args[1].c_str(), "%lu", &power) != 1) {
+ setErrorMessage("Invalid argument");
+ return false;
+ }
+
+ if (power < 2 || power > 20)
+ {
+ setErrorMessage("Invalid minimum transmit power for sweep survey mode, expects (2-20)");
+ return false;
+ }
+//ToDo: Output warning if > maximum power.
+ return true;
+ }
+
+ setErrorMessage("Invalid arguments");
+ return false;
+}
+
diff --git a/CommandTerminal/CmdMinimumPower.h b/CommandTerminal/CmdMinimumPower.h
new file mode 100644
index 0000000..a8656ee
--- /dev/null
+++ b/CommandTerminal/CmdMinimumPower.h
@@ -0,0 +1,21 @@
+#ifndef __CMDMINIMUMPOWER_H__
+#define __CMDMINIMUMPOWER_H__
+
+#include "Command.h"
+
+class CommandTerminal;
+
+class CmdMinimumPower: public Command
+{
+
+public:
+
+ CmdMinimumPower(mDot* dot, mts::MTSSerial& serial);
+ virtual uint32_t action(std::vector<std::string> args);
+ virtual bool verify(std::vector<std::string> args);
+
+private:
+ mts::MTSSerial& _serial;
+};
+
+#endif // __CMDMINIMUMPOWER_H__
diff --git a/CommandTerminal/CmdMinimumSize.cpp b/CommandTerminal/CmdMinimumSize.cpp
new file mode 100644
index 0000000..7091bd8
--- /dev/null
+++ b/CommandTerminal/CmdMinimumSize.cpp
@@ -0,0 +1,62 @@
+#include "CmdMinimumSize.h"
+
+CmdMinimumSize::CmdMinimumSize(mDot* dot, mts::MTSSerial& serial) :
+ Command(dot, "Minimum Size", "AT+MINSIZE", "Set the minimum payload size for sweep survey mode"), _serial(serial)
+{
+ _help = std::string(text()) + ": " + std::string(desc());
+ _usage = "(11-242)";
+ _queryable = true;
+}
+
+uint32_t CmdMinimumSize::action(std::vector<std::string> args)
+{
+ if (args.size() == 1)
+ {
+ if (_dot->getVerbose())
+ _serial.writef("Minimum Size: ");
+//ToDo: Change from _dot->getTxPower() to the structure we will use for this.
+ _serial.writef("%lu\r\n", _dot->getTxPower());
+ }
+ else if (args.size() == 2)
+ {
+ int32_t code;
+ uint32_t power = 0;
+ sscanf(args[1].c_str(), "%lu", &power);
+
+ if ((code = _dot->setTxPower(power)) != mDot::MDOT_OK)
+ {
+ std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError();
+ setErrorMessage(error);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+bool CmdMinimumSize::verify(std::vector<std::string> args)
+{
+ if (args.size() == 1)
+ return true;
+
+ if (args.size() == 2)
+ {
+ uint32_t power = 0;
+ if (sscanf(args[1].c_str(), "%lu", &power) != 1) {
+ setErrorMessage("Invalid argument");
+ return false;
+ }
+
+ if (power < 11 || power > 242)
+ {
+ setErrorMessage("Invalid minimum payload size, expects (11-242)");
+ return false;
+ }
+//ToDo: Output warning if > maximum size.
+ return true;
+ }
+
+ setErrorMessage("Invalid arguments");
+ return false;
+}
+
diff --git a/CommandTerminal/CmdMinimumSize.h b/CommandTerminal/CmdMinimumSize.h
new file mode 100644
index 0000000..ec5d3aa
--- /dev/null
+++ b/CommandTerminal/CmdMinimumSize.h
@@ -0,0 +1,21 @@
+#ifndef __CMDMINIMUMSIZE_H__
+#define __CMDMINIMUMSIZE_H__
+
+#include "Command.h"
+
+class CommandTerminal;
+
+class CmdMinimumSize: public Command
+{
+
+public:
+
+ CmdMinimumSize(mDot* dot, mts::MTSSerial& serial);
+ virtual uint32_t action(std::vector<std::string> args);
+ virtual bool verify(std::vector<std::string> args);
+
+private:
+ mts::MTSSerial& _serial;
+};
+
+#endif // __CMDMINIMUMSIZE_H__
diff --git a/CommandTerminal/CommandTerminal.cpp b/CommandTerminal/CommandTerminal.cpp
index 265009e..28c047f 100644
--- a/CommandTerminal/CommandTerminal.cpp
+++ b/CommandTerminal/CommandTerminal.cpp
@@ -57,6 +57,16 @@ CommandTerminal::CommandTerminal(mts::MTSSerial& serial, mDot* dot)
addCommand(new CmdNetworkJoinMode(_dot, serial));
addCommand(new CmdTxDataRate(_dot, serial));
addCommand(new CmdTxPower(_dot, serial));
+
+ addCommand(new CmdMinimumSize(_dot, serial));
+ addCommand(new CmdMaximumSize(_dot, serial));
+ addCommand(new CmdMinimumPower(_dot, serial));
+ addCommand(new CmdMaximumPower(_dot, serial));
+ addCommand(new CmdData(_dot, serial));
+ addCommand(new CmdGetSurveyDataFile(_dot, serial));
+ addCommand(new CmdDeleteSurveyDataFile(_dot, serial));
+ addCommand(new CmdExit(_dot, serial));
+
}
void CommandTerminal::printHelp() {
diff --git a/CommandTerminal/Commands.h b/CommandTerminal/Commands.h
index 5b699f4..3797036 100644
--- a/CommandTerminal/Commands.h
+++ b/CommandTerminal/Commands.h
@@ -17,3 +17,12 @@
#include "CmdTxDataRate.h"
#include "CmdTxPower.h"
#include "CmdFrequencySubBand.h"
+
+#include "CmdMinimumSize.h"
+#include "CmdMaximumSize.h"
+#include "CmdMinimumPower.h"
+#include "CmdMaximumPower.h"
+#include "CmdData.h"
+#include "CmdGetSurveyDataFile.h"
+#include "CmdDeleteSurveyDataFile.h"
+#include "CmdExit.h"