![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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
CommandTerminal/CmdWakeTimeout.cpp@4:666017851052, 2015-08-18 (annotated)
- Committer:
- Mike Fiore
- Date:
- Tue Aug 18 11:21:43 2015 -0500
- Revision:
- 4:666017851052
- Child:
- 9:ff62b20f7000
update mdot-firmware to 0.1.2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
4:666017851052 | 1 | #include "CmdWakeTimeout.h" |
Mike Fiore |
4:666017851052 | 2 | |
Mike Fiore |
4:666017851052 | 3 | CmdWakeTimeout::CmdWakeTimeout(mDot* dot, mts::MTSSerial& serial) : |
Mike Fiore |
4:666017851052 | 4 | Command(dot, "Wake Timeout", "AT+WTO", "Read serial data until timeout (milliseconds)"), _serial(serial) |
Mike Fiore |
4:666017851052 | 5 | { |
Mike Fiore |
4:666017851052 | 6 | _help = std::string(text()) + ": " + std::string(desc()); |
Mike Fiore |
4:666017851052 | 7 | _usage = "(0-65000) ms"; |
Mike Fiore |
4:666017851052 | 8 | _queryable = true; |
Mike Fiore |
4:666017851052 | 9 | } |
Mike Fiore |
4:666017851052 | 10 | |
Mike Fiore |
4:666017851052 | 11 | uint32_t CmdWakeTimeout::action(std::vector<std::string> args) |
Mike Fiore |
4:666017851052 | 12 | { |
Mike Fiore |
4:666017851052 | 13 | if (args.size() == 1) |
Mike Fiore |
4:666017851052 | 14 | { |
Mike Fiore |
4:666017851052 | 15 | if (_dot->getVerbose()) |
Mike Fiore |
4:666017851052 | 16 | _serial.writef("%s: ", name()); |
Mike Fiore |
4:666017851052 | 17 | |
Mike Fiore |
4:666017851052 | 18 | _serial.writef("%lu\r\n", _dot->getWakeTimeout()); |
Mike Fiore |
4:666017851052 | 19 | } |
Mike Fiore |
4:666017851052 | 20 | else if (args.size() == 2) |
Mike Fiore |
4:666017851052 | 21 | { |
Mike Fiore |
4:666017851052 | 22 | int32_t code; |
Mike Fiore |
4:666017851052 | 23 | uint32_t timeout; |
Mike Fiore |
4:666017851052 | 24 | sscanf(args[1].c_str(), "%lu", &timeout); |
Mike Fiore |
4:666017851052 | 25 | |
Mike Fiore |
4:666017851052 | 26 | if ((code = _dot->setWakeTimeout(timeout)) != mDot::MDOT_OK) { |
Mike Fiore |
4:666017851052 | 27 | std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError(); |
Mike Fiore |
4:666017851052 | 28 | setErrorMessage(error); |
Mike Fiore |
4:666017851052 | 29 | return 1; |
Mike Fiore |
4:666017851052 | 30 | } |
Mike Fiore |
4:666017851052 | 31 | } |
Mike Fiore |
4:666017851052 | 32 | |
Mike Fiore |
4:666017851052 | 33 | return 0; |
Mike Fiore |
4:666017851052 | 34 | } |
Mike Fiore |
4:666017851052 | 35 | |
Mike Fiore |
4:666017851052 | 36 | bool CmdWakeTimeout::verify(std::vector<std::string> args) |
Mike Fiore |
4:666017851052 | 37 | { |
Mike Fiore |
4:666017851052 | 38 | if (args.size() == 1) |
Mike Fiore |
4:666017851052 | 39 | return true; |
Mike Fiore |
4:666017851052 | 40 | |
Mike Fiore |
4:666017851052 | 41 | if (args.size() == 2) |
Mike Fiore |
4:666017851052 | 42 | { |
Mike Fiore |
4:666017851052 | 43 | uint32_t timeout; |
Mike Fiore |
4:666017851052 | 44 | if (sscanf(args[1].c_str(), "%lu", &timeout) != 1) { |
Mike Fiore |
4:666017851052 | 45 | setErrorMessage("Invalid argument"); |
Mike Fiore |
4:666017851052 | 46 | return false; |
Mike Fiore |
4:666017851052 | 47 | } |
Mike Fiore |
4:666017851052 | 48 | |
Mike Fiore |
4:666017851052 | 49 | if (timeout < 0 || timeout > 65000) { |
Mike Fiore |
4:666017851052 | 50 | setErrorMessage("Invalid timeout, expects (0-65000) ms"); |
Mike Fiore |
4:666017851052 | 51 | return false; |
Mike Fiore |
4:666017851052 | 52 | } |
Mike Fiore |
4:666017851052 | 53 | |
Mike Fiore |
4:666017851052 | 54 | return true; |
Mike Fiore |
4:666017851052 | 55 | } |
Mike Fiore |
4:666017851052 | 56 | |
Mike Fiore |
4:666017851052 | 57 | setErrorMessage("Invalid arguments"); |
Mike Fiore |
4:666017851052 | 58 | return false; |
Mike Fiore |
4:666017851052 | 59 | } |