![](/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/CmdDeviceClass.cpp@18:f5d28d621bb0, 2018-03-02 (annotated)
- Committer:
- pferland
- Date:
- Fri Mar 02 20:01:38 2018 +0000
- Revision:
- 18:f5d28d621bb0
- Parent:
- 14:f9a77400b622
Added ability to force the AT terminal to use the USB debug port
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 |
14:f9a77400b622 | 4 | CmdDeviceClass::CmdDeviceClass() |
Mike Fiore |
9:ff62b20f7000 | 5 | : |
Mike Fiore |
14:f9a77400b622 | 6 | Command("Device Class", "AT+DC", "Device class (A,B,C)", "(A,B,C)") { |
Mike Fiore |
14:f9a77400b622 | 7 | |
Mike Fiore |
9:ff62b20f7000 | 8 | _queryable = true; |
Mike Fiore |
9:ff62b20f7000 | 9 | } |
Mike Fiore |
9:ff62b20f7000 | 10 | |
Mike Fiore |
9:ff62b20f7000 | 11 | CmdDeviceClass::~CmdDeviceClass() { |
Mike Fiore |
9:ff62b20f7000 | 12 | |
Mike Fiore |
9:ff62b20f7000 | 13 | } |
Mike Fiore |
9:ff62b20f7000 | 14 | |
Mike Fiore |
9:ff62b20f7000 | 15 | uint32_t CmdDeviceClass::action(std::vector<std::string> args) { |
Mike Fiore |
9:ff62b20f7000 | 16 | |
Mike Fiore |
9:ff62b20f7000 | 17 | if (args.size() == 1) { |
Mike Fiore |
14:f9a77400b622 | 18 | CommandTerminal::Serial()->writef("%s\r\n", CommandTerminal::Dot()->getClass().c_str()); |
Mike Fiore |
9:ff62b20f7000 | 19 | } else { |
Mike Fiore |
14:f9a77400b622 | 20 | if (CommandTerminal::Dot()->setClass(args[1]) != mDot::MDOT_OK) { |
Mike Fiore |
14:f9a77400b622 | 21 | CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; |
Mike Fiore |
9:ff62b20f7000 | 22 | return 1; |
Mike Fiore |
9:ff62b20f7000 | 23 | } |
Mike Fiore |
9:ff62b20f7000 | 24 | } |
Mike Fiore |
9:ff62b20f7000 | 25 | |
Mike Fiore |
9:ff62b20f7000 | 26 | return 0; |
Mike Fiore |
9:ff62b20f7000 | 27 | } |
Mike Fiore |
9:ff62b20f7000 | 28 | |
Mike Fiore |
9:ff62b20f7000 | 29 | bool CmdDeviceClass::verify(std::vector<std::string> args) |
Mike Fiore |
9:ff62b20f7000 | 30 | { |
Mike Fiore |
9:ff62b20f7000 | 31 | if (args.size() == 1) |
Mike Fiore |
9:ff62b20f7000 | 32 | return true; |
Mike Fiore |
9:ff62b20f7000 | 33 | |
Mike Fiore |
9:ff62b20f7000 | 34 | if (args.size() == 2) { |
Mike Fiore |
9:ff62b20f7000 | 35 | args[1] = mts::Text::toUpper(args[1]); |
Mike Fiore |
9:ff62b20f7000 | 36 | if (args[1] == "A" || args[1] == "B" || args[1] == "C") { |
Mike Fiore |
9:ff62b20f7000 | 37 | return true; |
Mike Fiore |
9:ff62b20f7000 | 38 | } |
Mike Fiore |
9:ff62b20f7000 | 39 | } |
Mike Fiore |
9:ff62b20f7000 | 40 | |
Mike Fiore |
14:f9a77400b622 | 41 | CommandTerminal::setErrorMessage("Invalid arguments"); |
Mike Fiore |
9:ff62b20f7000 | 42 | return false; |
Mike Fiore |
9:ff62b20f7000 | 43 | } |