mDot AT-Firmware for testing
Dependencies: MTS-Serial libmDot-mbed5
Fork of Dot-AT-Firmware by
CommandTerminal/CmdDisableDutyCycle.cpp@16:3b1d46c1db11, 2017-08-14 (annotated)
- Committer:
- Fran6
- Date:
- Mon Aug 14 12:40:21 2017 +0000
- Revision:
- 16:3b1d46c1db11
- Parent:
- 14:f9a77400b622
mDot AT-Firmware
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
14:f9a77400b622 | 1 | #include "CmdDisableDutyCycle.h" |
Mike Fiore |
14:f9a77400b622 | 2 | |
Mike Fiore |
14:f9a77400b622 | 3 | CmdDisableDutyCycle::CmdDisableDutyCycle() |
Mike Fiore |
14:f9a77400b622 | 4 | : Command("Disable Duty Cycle", "AT+DD", "Disable duty cycle for TESTING PURPOSES ONLY!!! This setting will not be saved to config.", "(0-1)") { |
Mike Fiore |
14:f9a77400b622 | 5 | _queryable = true; |
Mike Fiore |
14:f9a77400b622 | 6 | } |
Mike Fiore |
14:f9a77400b622 | 7 | |
Mike Fiore |
14:f9a77400b622 | 8 | uint32_t CmdDisableDutyCycle::action(std::vector<std::string> args) { |
Mike Fiore |
14:f9a77400b622 | 9 | |
Mike Fiore |
14:f9a77400b622 | 10 | if (args.size() == 1) { |
Mike Fiore |
14:f9a77400b622 | 11 | CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getDisableDutyCycle()); |
Mike Fiore |
14:f9a77400b622 | 12 | } else if (args.size() == 2) { |
Mike Fiore |
14:f9a77400b622 | 13 | CommandTerminal::Dot()->setDisableDutyCycle(args[1] == "1"); |
Mike Fiore |
14:f9a77400b622 | 14 | } |
Mike Fiore |
14:f9a77400b622 | 15 | |
Mike Fiore |
14:f9a77400b622 | 16 | return 0; |
Mike Fiore |
14:f9a77400b622 | 17 | } |
Mike Fiore |
14:f9a77400b622 | 18 | |
Mike Fiore |
14:f9a77400b622 | 19 | bool CmdDisableDutyCycle::verify(std::vector<std::string> args) { |
Mike Fiore |
14:f9a77400b622 | 20 | |
Mike Fiore |
14:f9a77400b622 | 21 | if (args.size() > 2) { |
Mike Fiore |
14:f9a77400b622 | 22 | CommandTerminal::setErrorMessage("Invalid parameter, expects (0-1)"); |
Mike Fiore |
14:f9a77400b622 | 23 | return false; |
Mike Fiore |
14:f9a77400b622 | 24 | } |
Mike Fiore |
14:f9a77400b622 | 25 | |
Mike Fiore |
14:f9a77400b622 | 26 | if (args.size() == 2) { |
Mike Fiore |
14:f9a77400b622 | 27 | int bytes; |
Mike Fiore |
14:f9a77400b622 | 28 | |
Mike Fiore |
14:f9a77400b622 | 29 | sscanf(args[1].c_str(), "%d", &bytes); |
Mike Fiore |
14:f9a77400b622 | 30 | |
Mike Fiore |
14:f9a77400b622 | 31 | if (!(bytes == 0 || bytes == 1)) { |
Mike Fiore |
14:f9a77400b622 | 32 | CommandTerminal::setErrorMessage("Invalid parameter, expects (0-1)"); |
Mike Fiore |
14:f9a77400b622 | 33 | return false; |
Mike Fiore |
14:f9a77400b622 | 34 | } |
Mike Fiore |
14:f9a77400b622 | 35 | } |
Mike Fiore |
14:f9a77400b622 | 36 | |
Mike Fiore |
14:f9a77400b622 | 37 | return true; |
Mike Fiore |
14:f9a77400b622 | 38 | } |