few changes for RTS/CTS control
Dependencies: MTS-Serial libmDot mbed-rtos mbed
Fork of mDot_AT_firmware by
CommandTerminal/CmdPreserveSession.cpp@11:77b7911263da, 2016-10-25 (annotated)
- Committer:
- serg838
- Date:
- Tue Oct 25 05:39:39 2016 +0000
- Revision:
- 11:77b7911263da
- Parent:
- 9:ff62b20f7000
RTS/CTS changes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
9:ff62b20f7000 | 1 | /* |
Mike Fiore |
9:ff62b20f7000 | 2 | * CmdPreserveSession.cpp |
Mike Fiore |
9:ff62b20f7000 | 3 | * |
Mike Fiore |
9:ff62b20f7000 | 4 | * Created on: Nov 4, 2015 |
Mike Fiore |
9:ff62b20f7000 | 5 | * Author: jreiss |
Mike Fiore |
9:ff62b20f7000 | 6 | */ |
Mike Fiore |
9:ff62b20f7000 | 7 | |
Mike Fiore |
9:ff62b20f7000 | 8 | #include "CmdPreserveSession.h" |
Mike Fiore |
9:ff62b20f7000 | 9 | |
Mike Fiore |
9:ff62b20f7000 | 10 | CmdPreserveSession::CmdPreserveSession(mDot* dot, mts::MTSSerial& serial) |
Mike Fiore |
9:ff62b20f7000 | 11 | : |
Mike Fiore |
9:ff62b20f7000 | 12 | Command(dot, "Preserve Session", "AT+PS", "Save network session info through reset or power down in AUTO_OTA mode (0:off, 1:on)"), |
Mike Fiore |
9:ff62b20f7000 | 13 | _serial(serial) |
Mike Fiore |
9:ff62b20f7000 | 14 | { |
Mike Fiore |
9:ff62b20f7000 | 15 | _help = std::string(text()) + ": " + std::string(desc()); |
Mike Fiore |
9:ff62b20f7000 | 16 | _usage = "(0,1)"; |
Mike Fiore |
9:ff62b20f7000 | 17 | _queryable = true; |
Mike Fiore |
9:ff62b20f7000 | 18 | } |
Mike Fiore |
9:ff62b20f7000 | 19 | |
Mike Fiore |
9:ff62b20f7000 | 20 | CmdPreserveSession::~CmdPreserveSession() |
Mike Fiore |
9:ff62b20f7000 | 21 | { |
Mike Fiore |
9:ff62b20f7000 | 22 | // TODO Auto-generated destructor stub |
Mike Fiore |
9:ff62b20f7000 | 23 | } |
Mike Fiore |
9:ff62b20f7000 | 24 | |
Mike Fiore |
9:ff62b20f7000 | 25 | uint32_t CmdPreserveSession::action(std::vector<std::string> args) { |
Mike Fiore |
9:ff62b20f7000 | 26 | |
Mike Fiore |
9:ff62b20f7000 | 27 | if (args.size() == 1) { |
Mike Fiore |
9:ff62b20f7000 | 28 | if (_dot->getVerbose()) |
Mike Fiore |
9:ff62b20f7000 | 29 | _serial.writef("Preserve Session: "); |
Mike Fiore |
9:ff62b20f7000 | 30 | |
Mike Fiore |
9:ff62b20f7000 | 31 | _serial.writef("%u\r\n", _dot->getPreserveSession()); |
Mike Fiore |
9:ff62b20f7000 | 32 | } else { |
Mike Fiore |
9:ff62b20f7000 | 33 | _dot->setPreserveSession(args[1] == "1"); |
Mike Fiore |
9:ff62b20f7000 | 34 | } |
Mike Fiore |
9:ff62b20f7000 | 35 | |
Mike Fiore |
9:ff62b20f7000 | 36 | return mDot::MDOT_OK; |
Mike Fiore |
9:ff62b20f7000 | 37 | } |
Mike Fiore |
9:ff62b20f7000 | 38 | |
Mike Fiore |
9:ff62b20f7000 | 39 | bool CmdPreserveSession::verify(std::vector<std::string> args) { |
Mike Fiore |
9:ff62b20f7000 | 40 | if (args.size() == 1) |
Mike Fiore |
9:ff62b20f7000 | 41 | return true; |
Mike Fiore |
9:ff62b20f7000 | 42 | |
Mike Fiore |
9:ff62b20f7000 | 43 | if (args.size() == 2) { |
Mike Fiore |
9:ff62b20f7000 | 44 | |
Mike Fiore |
9:ff62b20f7000 | 45 | if (args[1] != "1" && args[1] != "0") { |
Mike Fiore |
9:ff62b20f7000 | 46 | setErrorMessage("Invalid parameter, expects (0: off, 1: on)"); |
Mike Fiore |
9:ff62b20f7000 | 47 | return false; |
Mike Fiore |
9:ff62b20f7000 | 48 | } |
Mike Fiore |
9:ff62b20f7000 | 49 | |
Mike Fiore |
9:ff62b20f7000 | 50 | return true; |
Mike Fiore |
9:ff62b20f7000 | 51 | } |
Mike Fiore |
9:ff62b20f7000 | 52 | |
Mike Fiore |
9:ff62b20f7000 | 53 | setErrorMessage("Invalid arguments"); |
Mike Fiore |
9:ff62b20f7000 | 54 | return false; |
Mike Fiore |
9:ff62b20f7000 | 55 | } |