AT terminal for the mDot using the USB debug port instead of the serial port.
Dependencies: MTS-Serial libmDot-mbed5
Fork of Dot-AT-Firmware by
Diff: CommandTerminal/CmdJoinDelay.cpp
- Revision:
- 14:f9a77400b622
- Parent:
- 9:ff62b20f7000
--- a/CommandTerminal/CmdJoinDelay.cpp Fri Nov 04 19:10:24 2016 +0000 +++ b/CommandTerminal/CmdJoinDelay.cpp Fri Nov 04 14:25:43 2016 -0500 @@ -7,13 +7,10 @@ #include "CmdJoinDelay.h" -CmdJoinDelay::CmdJoinDelay(mDot* dot, mts::MTSSerial& serial) +CmdJoinDelay::CmdJoinDelay() : - Command(dot, "Join Delay", "AT+JD", "Number of seconds before receive windows are opened for join (1 - 15)"), - _serial(serial) -{ - _help = std::string(text()) + ": " + std::string(desc()); - _usage = "(1-15)"; + Command("Join Delay", "AT+JD", "Number of seconds before receive windows are opened for join (1 - 15)", "(1-15)") { + _queryable = true; } @@ -23,19 +20,16 @@ } uint32_t CmdJoinDelay::action(std::vector<std::string> args) { + if (args.size() == 1) { - if (_dot->getVerbose()) - _serial.writef("Join Delay: "); - - _serial.writef("%u\r\n", _dot->getJoinDelay()); + CommandTerminal::Serial()->writef("%u\r\n", CommandTerminal::Dot()->getJoinDelay()); } else if (args.size() == 2) { - int32_t code; uint32_t joinDelay; sscanf(args[1].c_str(), "%lu", &joinDelay); - if ((code = _dot->setJoinDelay(joinDelay)) != mDot::MDOT_OK) { + if (CommandTerminal::Dot()->setJoinDelay(joinDelay) != mDot::MDOT_OK) { - setErrorMessage(_dot->getLastError());; + CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; return 1; } } @@ -51,13 +45,13 @@ int joinDelay; if (sscanf(args[1].c_str(), "%d", &joinDelay) == 1) { if (joinDelay > 15 || joinDelay < 1) { - setErrorMessage("Invalid join delay, expects (1-15)"); + CommandTerminal::setErrorMessage("Invalid join delay, expects (1-15)"); return false; } return true; } } - setErrorMessage("Invalid arguments"); + CommandTerminal::setErrorMessage("Invalid arguments"); return false; }