dev
Dependencies: MTS-Serial libmDot-mbed5
Fork of Dot-AT-Firmware by
Diff: CommandTerminal/CmdJoinRequest.cpp
- Revision:
- 14:f9a77400b622
- Parent:
- 9:ff62b20f7000
--- a/CommandTerminal/CmdJoinRequest.cpp Fri Nov 04 19:10:24 2016 +0000 +++ b/CommandTerminal/CmdJoinRequest.cpp Fri Nov 04 14:25:43 2016 -0500 @@ -1,34 +1,35 @@ #include "CmdJoinRequest.h" #include "CommandTerminal.h" -CmdJoinRequest::CmdJoinRequest(mDot* dot, mts::MTSSerial& serial) +CmdJoinRequest::CmdJoinRequest() : - Command(dot, "Join Network", "AT+JOIN", "Join network, provide argument of '1' to force join (acquire network address and session keys)"), - _serial(serial) { - _help = std::string(text()) + ": " + std::string(desc()); - _usage = "(force:1)"; + Command("Join Network", "AT+JOIN", "Join network, provide argument of '1' to force join (acquire network address and session keys)", "(force:1)") { + } uint32_t CmdJoinRequest::action(std::vector<std::string> args) { - int32_t code; + std::string buf; if (args.size() > 1 && args[1] == "1") - _dot->resetNetworkSession(); + CommandTerminal::Dot()->resetNetworkSession(); - if (_dot->getJoinMode() == 0) { - _serial.writef("Join not necessary for Manual Join Mode\r\n"); + if (CommandTerminal::Dot()->getJoinMode() == 0) { + CommandTerminal::Serial()->writef("Join not necessary for Manual Join Mode\r\n"); + return 0; + } else if (CommandTerminal::Dot()->getJoinMode() == 3) { + CommandTerminal::Serial()->writef("Join not necessary for Peer-to-Peer\r\n"); return 0; } - code = _dot->joinNetworkOnce(); + int32_t code = CommandTerminal::Dot()->joinNetworkOnce(); if (code == mDot::MDOT_OK) { - _serial.writef("Successfully joined network\r\n"); + CommandTerminal::Serial()->writef("Successfully joined network\r\n"); return 0; } else { - std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError(); - setErrorMessage(_dot->getLastError());; + std::string error = mDot::getReturnCodeString(code) + " - " + CommandTerminal::Dot()->getLastError(); + CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError()); } return 1; @@ -38,6 +39,6 @@ if (args.size() == 1 || (args.size() == 2 && args[1] == "1")) return true; - setErrorMessage("Invalid arguments"); + CommandTerminal::setErrorMessage("Invalid arguments"); return false; }