few changes for RTS/CTS control
Dependencies: MTS-Serial libmDot mbed-rtos mbed
Fork of mDot_AT_firmware by
CommandTerminal/CmdWakeDelay.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 |
4:666017851052 | 1 | #include "CmdWakeDelay.h" |
Mike Fiore |
4:666017851052 | 2 | |
Mike Fiore |
4:666017851052 | 3 | CmdWakeDelay::CmdWakeDelay(mDot* dot, mts::MTSSerial& serial) : |
Mike Fiore |
4:666017851052 | 4 | Command(dot, "Wake Delay", "AT+WD", "Time to wait for data after wakeup signal (milliseconds)"), |
Mike Fiore |
4:666017851052 | 5 | _serial(serial) |
Mike Fiore |
4:666017851052 | 6 | { |
Mike Fiore |
4:666017851052 | 7 | _help = std::string(text()) + ": " + std::string(desc()); |
Mike Fiore |
4:666017851052 | 8 | _usage = "(2-2147483647) ms"; |
Mike Fiore |
4:666017851052 | 9 | _queryable = true; |
Mike Fiore |
4:666017851052 | 10 | } |
Mike Fiore |
4:666017851052 | 11 | |
Mike Fiore |
4:666017851052 | 12 | uint32_t CmdWakeDelay::action(std::vector<std::string> args) |
Mike Fiore |
4:666017851052 | 13 | { |
Mike Fiore |
4:666017851052 | 14 | if (args.size() == 1) |
Mike Fiore |
4:666017851052 | 15 | { |
Mike Fiore |
4:666017851052 | 16 | if (_dot->getVerbose()) |
Mike Fiore |
4:666017851052 | 17 | _serial.writef("%s: ", name()); |
Mike Fiore |
4:666017851052 | 18 | |
Mike Fiore |
4:666017851052 | 19 | _serial.writef("%lu\r\n", _dot->getWakeDelay()); |
Mike Fiore |
4:666017851052 | 20 | } |
Mike Fiore |
4:666017851052 | 21 | else if (args.size() == 2) |
Mike Fiore |
4:666017851052 | 22 | { |
Mike Fiore |
4:666017851052 | 23 | int32_t code; |
Mike Fiore |
9:ff62b20f7000 | 24 | int delay; |
Mike Fiore |
9:ff62b20f7000 | 25 | sscanf(args[1].c_str(), "%d", &delay); |
Mike Fiore |
4:666017851052 | 26 | |
Mike Fiore |
4:666017851052 | 27 | if ((code = _dot->setWakeDelay(delay)) != mDot::MDOT_OK) { |
Mike Fiore |
9:ff62b20f7000 | 28 | setErrorMessage(_dot->getLastError());; |
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 CmdWakeDelay::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 |
9:ff62b20f7000 | 43 | int delay; |
Mike Fiore |
9:ff62b20f7000 | 44 | if (sscanf(args[1].c_str(), "%d", &delay) != 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 (delay < 2 || delay > INT_MAX) { |
Mike Fiore |
4:666017851052 | 50 | setErrorMessage("Invalid delay, expects (2-2147483647) 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 | } |