summaryrefslogtreecommitdiff
path: root/CommandTerminal/CmdMaximumSize.cpp
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/CmdMaximumSize.cpp
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/CmdMaximumSize.cpp')
-rw-r--r--CommandTerminal/CmdMaximumSize.cpp62
1 files changed, 62 insertions, 0 deletions
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;
+}
+