From f484beed77531d7ef2da65cf049fe9c4ac6b7d08 Mon Sep 17 00:00:00 2001 From: Leon Lindenfelser Date: Mon, 16 Nov 2015 16:18:09 -0600 Subject: Added all the new dotbox commands with some detail work still needed --- CommandTerminal/CmdData.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 CommandTerminal/CmdData.cpp (limited to 'CommandTerminal/CmdData.cpp') 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 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 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; + +} + -- cgit v1.2.3 From ce5c78c53be8d66da4a2cccdf18b622c0b77e773 Mon Sep 17 00:00:00 2001 From: Leon Lindenfelser Date: Wed, 18 Nov 2015 11:16:11 -0600 Subject: Added functionality to get the guts of these commands working with storage mapped into unused mDot commands. Over write the mDot defaults in these storage locations with the appropriate defaults for these 5 commands. --- CommandTerminal/CmdData.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'CommandTerminal/CmdData.cpp') diff --git a/CommandTerminal/CmdData.cpp b/CommandTerminal/CmdData.cpp index 339fc4b..4b31de6 100644 --- a/CommandTerminal/CmdData.cpp +++ b/CommandTerminal/CmdData.cpp @@ -1,5 +1,7 @@ #include "CmdData.h" +//SPECIAL NOTE: +Data is stored in the LoraConfig StartUpMode field. We decided to use 5 LoRaConfig locations, +// that are not used for the DotBox, for the 5 DotBox settings... +minsize, +maxsize, +minpwr, +maxpwr and +data. 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) { @@ -14,15 +16,14 @@ uint32_t CmdData::action(std::vector args) { 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()); + _serial.writef("%d\r\n", _dot->getStartUpMode()); } else if (args.size() == 2) { int32_t code; bool enable = (args[1] == "1"); - if ((code = _dot->setPublicNetwork(enable)) != mDot::MDOT_OK) { + if ((code = _dot->setStartUpMode(enable)) != mDot::MDOT_OK) { std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError(); setErrorMessage(error); return 1; -- cgit v1.2.3