![](/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/CmdTxDataRate.cpp@16:d5cf2af81a6d, 2017-06-19 (annotated)
- Committer:
- jenkins@jenkinsdm1
- Date:
- Mon Jun 19 14:33:21 2017 -0500
- Revision:
- 16:d5cf2af81a6d
- Parent:
- 14:f9a77400b622
mdot-firmware revision 3.0.0-rc7
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
1:e52ae6584f1c | 1 | #include "CmdTxDataRate.h" |
Mike Fiore |
9:ff62b20f7000 | 2 | #include "MTSText.h" |
Mike Fiore |
9:ff62b20f7000 | 3 | #include "MTSLog.h" |
Mike Fiore |
1:e52ae6584f1c | 4 | |
Mike Fiore |
1:e52ae6584f1c | 5 | |
Mike Fiore |
14:f9a77400b622 | 6 | CmdTxDataRate::CmdTxDataRate() |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 7 | : Command("Tx Data Rate", "AT+TXDR", "Set the Tx data rate for all channels", "7-10|DR0-DR15, Depends on Channel Plan") { |
Mike Fiore |
1:e52ae6584f1c | 8 | _queryable = true; |
Mike Fiore |
1:e52ae6584f1c | 9 | } |
Mike Fiore |
1:e52ae6584f1c | 10 | |
Mike Fiore |
9:ff62b20f7000 | 11 | uint32_t CmdTxDataRate::action(std::vector<std::string> args) { |
Mike Fiore |
1:e52ae6584f1c | 12 | if (args.size() == 1) |
Mike Fiore |
9:ff62b20f7000 | 13 | { |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 14 | CommandTerminal::Serial()->writef("DR%d - %s\r\n", CommandTerminal::Dot()->getTxDataRate(), CommandTerminal::Dot()->getDataRateDetails(CommandTerminal::Dot()->getTxDataRate()).c_str()); |
Mike Fiore |
9:ff62b20f7000 | 15 | } else if (args.size() == 2) { |
Mike Fiore |
9:ff62b20f7000 | 16 | std::string dr = mts::Text::toUpper(args[1]); |
Mike Fiore |
14:f9a77400b622 | 17 | |
Mike Fiore |
9:ff62b20f7000 | 18 | int datarate = -1; |
Mike Fiore |
1:e52ae6584f1c | 19 | uint8_t i; |
Mike Fiore |
1:e52ae6584f1c | 20 | |
Mike Fiore |
9:ff62b20f7000 | 21 | int res = sscanf(dr.c_str(), "%d", &datarate); |
Mike Fiore |
9:ff62b20f7000 | 22 | |
Mike Fiore |
9:ff62b20f7000 | 23 | if (res == 0) { |
Mike Fiore |
9:ff62b20f7000 | 24 | for (i = 0; i < 24; i++) { |
Mike Fiore |
9:ff62b20f7000 | 25 | if (mDot::DataRateStr(i).find(dr) != std::string::npos) { |
Mike Fiore |
9:ff62b20f7000 | 26 | datarate = i; |
Mike Fiore |
9:ff62b20f7000 | 27 | break; |
Mike Fiore |
9:ff62b20f7000 | 28 | } |
Mike Fiore |
9:ff62b20f7000 | 29 | } |
Mike Fiore |
1:e52ae6584f1c | 30 | } |
Mike Fiore |
1:e52ae6584f1c | 31 | |
Mike Fiore |
14:f9a77400b622 | 32 | if (CommandTerminal::Dot()->setTxDataRate(datarate) != mDot::MDOT_OK) { |
Mike Fiore |
14:f9a77400b622 | 33 | CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError()); |
Mike Fiore |
1:e52ae6584f1c | 34 | return 1; |
Mike Fiore |
1:e52ae6584f1c | 35 | } |
Mike Fiore |
1:e52ae6584f1c | 36 | } |
Mike Fiore |
1:e52ae6584f1c | 37 | |
Mike Fiore |
1:e52ae6584f1c | 38 | return 0; |
Mike Fiore |
1:e52ae6584f1c | 39 | } |
Mike Fiore |
1:e52ae6584f1c | 40 | |
Mike Fiore |
9:ff62b20f7000 | 41 | bool CmdTxDataRate::verify(std::vector<std::string> args) { |
Mike Fiore |
1:e52ae6584f1c | 42 | if (args.size() == 1) |
Mike Fiore |
1:e52ae6584f1c | 43 | return true; |
Mike Fiore |
1:e52ae6584f1c | 44 | |
Mike Fiore |
9:ff62b20f7000 | 45 | if (args.size() == 2) { |
Mike Fiore |
1:e52ae6584f1c | 46 | return true; |
Mike Fiore |
1:e52ae6584f1c | 47 | } |
Mike Fiore |
1:e52ae6584f1c | 48 | |
Mike Fiore |
14:f9a77400b622 | 49 | CommandTerminal::setErrorMessage("Invalid arguments"); |
Mike Fiore |
1:e52ae6584f1c | 50 | return false; |
Mike Fiore |
1:e52ae6584f1c | 51 | } |