![](/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/CmdAntennaGain.cpp@14:f9a77400b622, 2016-11-04 (annotated)
- Committer:
- Mike Fiore
- Date:
- Fri Nov 04 14:25:43 2016 -0500
- Revision:
- 14:f9a77400b622
- Parent:
- 9:ff62b20f7000
update from git revision 2.0.16
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
9:ff62b20f7000 | 1 | #include "CmdAntennaGain.h" |
Mike Fiore |
9:ff62b20f7000 | 2 | |
Mike Fiore |
14:f9a77400b622 | 3 | CmdAntennaGain::CmdAntennaGain() : |
Mike Fiore |
14:f9a77400b622 | 4 | Command("Antenna Gain", "AT+ANT", "Gain in dBi of installed antenna (-128-127)", "(-128-127)") |
Mike Fiore |
9:ff62b20f7000 | 5 | { |
Mike Fiore |
9:ff62b20f7000 | 6 | _queryable = true; |
Mike Fiore |
9:ff62b20f7000 | 7 | } |
Mike Fiore |
9:ff62b20f7000 | 8 | |
Mike Fiore |
9:ff62b20f7000 | 9 | uint32_t CmdAntennaGain::action(std::vector<std::string> args) |
Mike Fiore |
9:ff62b20f7000 | 10 | { |
Mike Fiore |
9:ff62b20f7000 | 11 | if (args.size() == 1) |
Mike Fiore |
9:ff62b20f7000 | 12 | { |
Mike Fiore |
14:f9a77400b622 | 13 | CommandTerminal::Serial()->writef("%d\r\n", CommandTerminal::Dot()->getAntennaGain()); |
Mike Fiore |
9:ff62b20f7000 | 14 | } |
Mike Fiore |
9:ff62b20f7000 | 15 | else if (args.size() == 2) |
Mike Fiore |
9:ff62b20f7000 | 16 | { |
Mike Fiore |
14:f9a77400b622 | 17 | |
Mike Fiore |
9:ff62b20f7000 | 18 | int gain; |
Mike Fiore |
9:ff62b20f7000 | 19 | sscanf(args[1].c_str(), "%d", &gain); |
Mike Fiore |
9:ff62b20f7000 | 20 | |
Mike Fiore |
14:f9a77400b622 | 21 | if (CommandTerminal::Dot()->setAntennaGain(gain) != mDot::MDOT_OK) |
Mike Fiore |
9:ff62b20f7000 | 22 | { |
Mike Fiore |
14:f9a77400b622 | 23 | CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError()); |
Mike Fiore |
9:ff62b20f7000 | 24 | return 1; |
Mike Fiore |
9:ff62b20f7000 | 25 | } |
Mike Fiore |
9:ff62b20f7000 | 26 | } |
Mike Fiore |
9:ff62b20f7000 | 27 | |
Mike Fiore |
9:ff62b20f7000 | 28 | return 0; |
Mike Fiore |
9:ff62b20f7000 | 29 | } |
Mike Fiore |
9:ff62b20f7000 | 30 | |
Mike Fiore |
9:ff62b20f7000 | 31 | bool CmdAntennaGain::verify(std::vector<std::string> args) |
Mike Fiore |
9:ff62b20f7000 | 32 | { |
Mike Fiore |
9:ff62b20f7000 | 33 | if (args.size() == 1) |
Mike Fiore |
9:ff62b20f7000 | 34 | return true; |
Mike Fiore |
9:ff62b20f7000 | 35 | |
Mike Fiore |
9:ff62b20f7000 | 36 | if (args.size() == 2) |
Mike Fiore |
9:ff62b20f7000 | 37 | { |
Mike Fiore |
9:ff62b20f7000 | 38 | int gain; |
Mike Fiore |
9:ff62b20f7000 | 39 | if (sscanf(args[1].c_str(), "%d", &gain) != 1) { |
Mike Fiore |
14:f9a77400b622 | 40 | CommandTerminal::setErrorMessage("Invalid argument"); |
Mike Fiore |
9:ff62b20f7000 | 41 | return false; |
Mike Fiore |
9:ff62b20f7000 | 42 | } |
Mike Fiore |
9:ff62b20f7000 | 43 | |
Mike Fiore |
9:ff62b20f7000 | 44 | if (gain < -128 || gain > 127) { |
Mike Fiore |
14:f9a77400b622 | 45 | CommandTerminal::setErrorMessage("Invalid gain, expects (-127-128)"); |
Mike Fiore |
9:ff62b20f7000 | 46 | return false; |
Mike Fiore |
9:ff62b20f7000 | 47 | } |
Mike Fiore |
9:ff62b20f7000 | 48 | |
Mike Fiore |
9:ff62b20f7000 | 49 | return true; |
Mike Fiore |
9:ff62b20f7000 | 50 | } |
Mike Fiore |
9:ff62b20f7000 | 51 | |
Mike Fiore |
14:f9a77400b622 | 52 | CommandTerminal::setErrorMessage("Invalid arguments"); |
Mike Fiore |
9:ff62b20f7000 | 53 | return false; |
Mike Fiore |
9:ff62b20f7000 | 54 | } |