few changes for RTS/CTS control
Dependencies: MTS-Serial libmDot mbed-rtos mbed
Fork of mDot_AT_firmware by
CommandTerminal/CmdDeviceClass.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 | #include "CmdDeviceClass.h" |
Mike Fiore |
9:ff62b20f7000 | 2 | #include "CommandTerminal.h" |
Mike Fiore |
9:ff62b20f7000 | 3 | |
Mike Fiore |
9:ff62b20f7000 | 4 | CmdDeviceClass::CmdDeviceClass(mDot* dot, mts::MTSSerial& serial) |
Mike Fiore |
9:ff62b20f7000 | 5 | : |
Mike Fiore |
9:ff62b20f7000 | 6 | Command(dot, "Device Class", "AT+DC", "Device class (A,B,C)"), |
Mike Fiore |
9:ff62b20f7000 | 7 | _serial(serial) { |
Mike Fiore |
9:ff62b20f7000 | 8 | _help = std::string(text()) + ": " + std::string(desc()); |
Mike Fiore |
9:ff62b20f7000 | 9 | _queryable = true; |
Mike Fiore |
9:ff62b20f7000 | 10 | _usage = "(A,B,C)"; |
Mike Fiore |
9:ff62b20f7000 | 11 | } |
Mike Fiore |
9:ff62b20f7000 | 12 | |
Mike Fiore |
9:ff62b20f7000 | 13 | CmdDeviceClass::~CmdDeviceClass() { |
Mike Fiore |
9:ff62b20f7000 | 14 | |
Mike Fiore |
9:ff62b20f7000 | 15 | } |
Mike Fiore |
9:ff62b20f7000 | 16 | |
Mike Fiore |
9:ff62b20f7000 | 17 | uint32_t CmdDeviceClass::action(std::vector<std::string> args) { |
Mike Fiore |
9:ff62b20f7000 | 18 | |
Mike Fiore |
9:ff62b20f7000 | 19 | if (args.size() == 1) { |
Mike Fiore |
9:ff62b20f7000 | 20 | if (_dot->getVerbose()) |
Mike Fiore |
9:ff62b20f7000 | 21 | _serial.writef("Device Class:\r\n"); |
Mike Fiore |
9:ff62b20f7000 | 22 | _serial.writef("%s\r\n", _dot->getClass().c_str()); |
Mike Fiore |
9:ff62b20f7000 | 23 | } else { |
Mike Fiore |
9:ff62b20f7000 | 24 | int32_t code; |
Mike Fiore |
9:ff62b20f7000 | 25 | if ((code = _dot->setClass(args[1])) != mDot::MDOT_OK) { |
Mike Fiore |
9:ff62b20f7000 | 26 | |
Mike Fiore |
9:ff62b20f7000 | 27 | setErrorMessage(_dot->getLastError());; |
Mike Fiore |
9:ff62b20f7000 | 28 | return 1; |
Mike Fiore |
9:ff62b20f7000 | 29 | } |
Mike Fiore |
9:ff62b20f7000 | 30 | } |
Mike Fiore |
9:ff62b20f7000 | 31 | |
Mike Fiore |
9:ff62b20f7000 | 32 | return 0; |
Mike Fiore |
9:ff62b20f7000 | 33 | } |
Mike Fiore |
9:ff62b20f7000 | 34 | |
Mike Fiore |
9:ff62b20f7000 | 35 | bool CmdDeviceClass::verify(std::vector<std::string> args) |
Mike Fiore |
9:ff62b20f7000 | 36 | { |
Mike Fiore |
9:ff62b20f7000 | 37 | if (args.size() == 1) |
Mike Fiore |
9:ff62b20f7000 | 38 | return true; |
Mike Fiore |
9:ff62b20f7000 | 39 | |
Mike Fiore |
9:ff62b20f7000 | 40 | if (args.size() == 2) { |
Mike Fiore |
9:ff62b20f7000 | 41 | args[1] = mts::Text::toUpper(args[1]); |
Mike Fiore |
9:ff62b20f7000 | 42 | if (args[1] == "A" || args[1] == "B" || args[1] == "C") { |
Mike Fiore |
9:ff62b20f7000 | 43 | return true; |
Mike Fiore |
9:ff62b20f7000 | 44 | } |
Mike Fiore |
9:ff62b20f7000 | 45 | } |
Mike Fiore |
9:ff62b20f7000 | 46 | |
Mike Fiore |
9:ff62b20f7000 | 47 | setErrorMessage("Invalid arguments"); |
Mike Fiore |
9:ff62b20f7000 | 48 | return false; |
Mike Fiore |
9:ff62b20f7000 | 49 | } |