![](/media/cache/profiles/f3bade0c47e6258ba21cc534c78993b8.jpg.50x50_q85.png)
This mDot firmware will allow USB to directly utilize AT command without the need the use of RS232 DB9 port.
Dependencies: MTS-Serial libmDot mbed-rtos mbed
Fork of mDot_USB_AT_firmware by
CommandTerminal/CmdAdaptiveDataRate.cpp@1:e52ae6584f1c, 2015-06-25 (annotated)
- Committer:
- Mike Fiore
- Date:
- Thu Jun 25 10:23:41 2015 -0500
- Revision:
- 1:e52ae6584f1c
- Child:
- 9:ff62b20f7000
update debug, add command source files
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
1:e52ae6584f1c | 1 | #include "CmdAdaptiveDataRate.h" |
Mike Fiore |
1:e52ae6584f1c | 2 | |
Mike Fiore |
1:e52ae6584f1c | 3 | |
Mike Fiore |
1:e52ae6584f1c | 4 | CmdAdaptiveDataRate::CmdAdaptiveDataRate(mDot* dot, mts::MTSSerial& serial) : |
Mike Fiore |
1:e52ae6584f1c | 5 | Command(dot, "Adaptive Data Rate", "AT+ADR", "Enable/disable Adaptive Data Rate (0: off, 1: on)"), _serial(serial) |
Mike Fiore |
1:e52ae6584f1c | 6 | { |
Mike Fiore |
1:e52ae6584f1c | 7 | _help = std::string(text()) + ": " + std::string(desc()); |
Mike Fiore |
1:e52ae6584f1c | 8 | _usage = "(0,1)"; |
Mike Fiore |
1:e52ae6584f1c | 9 | _queryable = true; |
Mike Fiore |
1:e52ae6584f1c | 10 | } |
Mike Fiore |
1:e52ae6584f1c | 11 | |
Mike Fiore |
1:e52ae6584f1c | 12 | uint32_t CmdAdaptiveDataRate::action(std::vector<std::string> args) |
Mike Fiore |
1:e52ae6584f1c | 13 | { |
Mike Fiore |
1:e52ae6584f1c | 14 | if (args.size() == 1) |
Mike Fiore |
1:e52ae6584f1c | 15 | { |
Mike Fiore |
1:e52ae6584f1c | 16 | if (_dot->getVerbose()) |
Mike Fiore |
1:e52ae6584f1c | 17 | _serial.writef("Adaptive Data Rate: "); |
Mike Fiore |
1:e52ae6584f1c | 18 | |
Mike Fiore |
1:e52ae6584f1c | 19 | _serial.writef("%d\r\n", _dot->getAdr()); |
Mike Fiore |
1:e52ae6584f1c | 20 | } |
Mike Fiore |
1:e52ae6584f1c | 21 | else if (args.size() == 2) |
Mike Fiore |
1:e52ae6584f1c | 22 | { |
Mike Fiore |
1:e52ae6584f1c | 23 | int32_t code; |
Mike Fiore |
1:e52ae6584f1c | 24 | bool enable = (args[1] == "1"); |
Mike Fiore |
1:e52ae6584f1c | 25 | if ((code = _dot->setAdr(enable)) != mDot::MDOT_OK) |
Mike Fiore |
1:e52ae6584f1c | 26 | { |
Mike Fiore |
1:e52ae6584f1c | 27 | std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError(); |
Mike Fiore |
1:e52ae6584f1c | 28 | setErrorMessage(error); |
Mike Fiore |
1:e52ae6584f1c | 29 | return 1; |
Mike Fiore |
1:e52ae6584f1c | 30 | } |
Mike Fiore |
1:e52ae6584f1c | 31 | } |
Mike Fiore |
1:e52ae6584f1c | 32 | |
Mike Fiore |
1:e52ae6584f1c | 33 | return 0; |
Mike Fiore |
1:e52ae6584f1c | 34 | } |
Mike Fiore |
1:e52ae6584f1c | 35 | |
Mike Fiore |
1:e52ae6584f1c | 36 | bool CmdAdaptiveDataRate::verify(std::vector<std::string> args) |
Mike Fiore |
1:e52ae6584f1c | 37 | { |
Mike Fiore |
1:e52ae6584f1c | 38 | if (args.size() == 1) |
Mike Fiore |
1:e52ae6584f1c | 39 | return true; |
Mike Fiore |
1:e52ae6584f1c | 40 | |
Mike Fiore |
1:e52ae6584f1c | 41 | if (args.size() == 2) |
Mike Fiore |
1:e52ae6584f1c | 42 | { |
Mike Fiore |
1:e52ae6584f1c | 43 | if (args[1] != "1" && args[1] != "0") { |
Mike Fiore |
1:e52ae6584f1c | 44 | setErrorMessage("Invalid parameter, expects (0: off, 1: on)"); |
Mike Fiore |
1:e52ae6584f1c | 45 | return false; |
Mike Fiore |
1:e52ae6584f1c | 46 | } |
Mike Fiore |
1:e52ae6584f1c | 47 | |
Mike Fiore |
1:e52ae6584f1c | 48 | return true; |
Mike Fiore |
1:e52ae6584f1c | 49 | } |
Mike Fiore |
1:e52ae6584f1c | 50 | |
Mike Fiore |
1:e52ae6584f1c | 51 | setErrorMessage("Invalid arguments"); |
Mike Fiore |
1:e52ae6584f1c | 52 | return false; |
Mike Fiore |
1:e52ae6584f1c | 53 | } |