![](/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/CmdRxFrequency.cpp@18:f5d28d621bb0, 2018-03-02 (annotated)
- Committer:
- pferland
- Date:
- Fri Mar 02 20:01:38 2018 +0000
- Revision:
- 18:f5d28d621bb0
- Parent:
- 16:d5cf2af81a6d
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 |
1:e52ae6584f1c | 1 | #include "CmdRxFrequency.h" |
Mike Fiore |
1:e52ae6584f1c | 2 | |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 3 | CmdRxFrequency::CmdRxFrequency() |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 4 | : |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 5 | Command("Rx Frequency", "AT+RXF", "Set the Rx frequency for +RECV,+RECVC", "SEE PLAN") |
Mike Fiore |
1:e52ae6584f1c | 6 | { |
Mike Fiore |
1:e52ae6584f1c | 7 | _queryable = true; |
Mike Fiore |
1:e52ae6584f1c | 8 | } |
Mike Fiore |
1:e52ae6584f1c | 9 | |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 10 | uint32_t CmdRxFrequency::action(std::vector<std::string> args) { |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 11 | if (args.size() == 1) { |
Mike Fiore |
14:f9a77400b622 | 12 | CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getRxFrequency()); |
Mike Fiore |
1:e52ae6584f1c | 13 | } |
Mike Fiore |
1:e52ae6584f1c | 14 | else if (args.size() == 2) |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 15 | { |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 16 | |
Mike Fiore |
9:ff62b20f7000 | 17 | int frequency = 0; |
Mike Fiore |
9:ff62b20f7000 | 18 | sscanf(args[1].c_str(), "%d", &frequency); |
Mike Fiore |
14:f9a77400b622 | 19 | if (CommandTerminal::Dot()->setRxFrequency(frequency) != mDot::MDOT_OK) |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 20 | { |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 21 | |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 22 | CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError()); |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 23 | ; |
Mike Fiore |
1:e52ae6584f1c | 24 | return 1; |
Mike Fiore |
1:e52ae6584f1c | 25 | } |
Mike Fiore |
1:e52ae6584f1c | 26 | } |
Mike Fiore |
1:e52ae6584f1c | 27 | |
Mike Fiore |
1:e52ae6584f1c | 28 | return 0; |
Mike Fiore |
1:e52ae6584f1c | 29 | } |
Mike Fiore |
1:e52ae6584f1c | 30 | |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 31 | bool CmdRxFrequency::verify(std::vector<std::string> args) { |
Mike Fiore |
1:e52ae6584f1c | 32 | if (args.size() == 1) |
Mike Fiore |
1:e52ae6584f1c | 33 | return true; |
Mike Fiore |
1:e52ae6584f1c | 34 | |
Mike Fiore |
1:e52ae6584f1c | 35 | if (args.size() == 2) |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 36 | { |
Mike Fiore |
9:ff62b20f7000 | 37 | int frequency; |
Mike Fiore |
9:ff62b20f7000 | 38 | if (sscanf(args[1].c_str(), "%d", &frequency) != 1) { |
Mike Fiore |
14:f9a77400b622 | 39 | CommandTerminal::setErrorMessage("Invalid argument"); |
Mike Fiore |
1:e52ae6584f1c | 40 | return false; |
Mike Fiore |
1:e52ae6584f1c | 41 | } |
Mike Fiore |
1:e52ae6584f1c | 42 | |
Mike Fiore |
14:f9a77400b622 | 43 | if (frequency != 0 && (frequency < int(CommandTerminal::Dot()->getMinFrequency()) || frequency > int(CommandTerminal::Dot()->getMaxFrequency()))) { |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 44 | char tmp[256]; |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 45 | sprintf(tmp, "Invalid frequency, expects (0,%lu-%lu)", CommandTerminal::Dot()->getMinFrequency(), CommandTerminal::Dot()->getMaxFrequency()); |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 46 | CommandTerminal::setErrorMessage(tmp); |
Mike Fiore |
1:e52ae6584f1c | 47 | return false; |
Mike Fiore |
1:e52ae6584f1c | 48 | } |
Mike Fiore |
1:e52ae6584f1c | 49 | |
Mike Fiore |
1:e52ae6584f1c | 50 | return true; |
Mike Fiore |
1:e52ae6584f1c | 51 | } |
Mike Fiore |
1:e52ae6584f1c | 52 | |
Mike Fiore |
14:f9a77400b622 | 53 | CommandTerminal::setErrorMessage("Invalid arguments"); |
Mike Fiore |
1:e52ae6584f1c | 54 | return false; |
Mike Fiore |
1:e52ae6584f1c | 55 | } |