Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MTS-Serial libxDot-mbed5
CommandTerminal/CmdDownlinkCounter.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 "CmdDownlinkCounter.h" |
| Mike Fiore |
9:ff62b20f7000 | 2 | |
| Mike Fiore |
14:f9a77400b622 | 3 | CmdDownlinkCounter::CmdDownlinkCounter() |
| Mike Fiore |
9:ff62b20f7000 | 4 | : |
| Mike Fiore |
14:f9a77400b622 | 5 | Command("Downlink Counter", "AT+DLC", "Get or set the downlink counter", "(0-4294967295)") { |
| Mike Fiore |
14:f9a77400b622 | 6 | |
| Mike Fiore |
9:ff62b20f7000 | 7 | _queryable = true; |
| Mike Fiore |
9:ff62b20f7000 | 8 | } |
| Mike Fiore |
9:ff62b20f7000 | 9 | |
| Mike Fiore |
9:ff62b20f7000 | 10 | uint32_t CmdDownlinkCounter::action(std::vector<std::string> args) { |
| Mike Fiore |
9:ff62b20f7000 | 11 | if (args.size() == 1) { |
| Mike Fiore |
14:f9a77400b622 | 12 | CommandTerminal::Serial()->writef("%u\r\n", CommandTerminal::Dot()->getDownLinkCounter()); |
| Mike Fiore |
9:ff62b20f7000 | 13 | } else if (args.size() == 2) { |
| Mike Fiore |
14:f9a77400b622 | 14 | uint32_t count; |
| Mike Fiore |
9:ff62b20f7000 | 15 | sscanf(args[1].c_str(), "%lu", &count); |
| Mike Fiore |
9:ff62b20f7000 | 16 | |
| Mike Fiore |
14:f9a77400b622 | 17 | if (CommandTerminal::Dot()->setDownLinkCounter(count) != mDot::MDOT_OK) { |
| Mike Fiore |
14:f9a77400b622 | 18 | CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; |
| Mike Fiore |
9:ff62b20f7000 | 19 | return 1; |
| Mike Fiore |
9:ff62b20f7000 | 20 | } |
| Mike Fiore |
9:ff62b20f7000 | 21 | } |
| Mike Fiore |
9:ff62b20f7000 | 22 | return 0; |
| Mike Fiore |
9:ff62b20f7000 | 23 | } |
| Mike Fiore |
9:ff62b20f7000 | 24 | |
| Mike Fiore |
9:ff62b20f7000 | 25 | bool CmdDownlinkCounter::verify(std::vector<std::string> args) { |
| Mike Fiore |
9:ff62b20f7000 | 26 | if (args.size() == 1) |
| Mike Fiore |
9:ff62b20f7000 | 27 | return true; |
| Mike Fiore |
9:ff62b20f7000 | 28 | |
| Mike Fiore |
9:ff62b20f7000 | 29 | if (args.size() == 2) { |
| Mike Fiore |
9:ff62b20f7000 | 30 | |
| Mike Fiore |
9:ff62b20f7000 | 31 | uint32_t count; |
| Mike Fiore |
9:ff62b20f7000 | 32 | if (sscanf(args[1].c_str(), "%lu", &count) == 1) { |
| Mike Fiore |
9:ff62b20f7000 | 33 | return true; |
| Mike Fiore |
9:ff62b20f7000 | 34 | } |
| Mike Fiore |
9:ff62b20f7000 | 35 | } |
| Mike Fiore |
9:ff62b20f7000 | 36 | |
| Mike Fiore |
14:f9a77400b622 | 37 | CommandTerminal::setErrorMessage("Invalid arguments"); |
| Mike Fiore |
9:ff62b20f7000 | 38 | return false; |
| Mike Fiore |
9:ff62b20f7000 | 39 | } |
| Mike Fiore |
9:ff62b20f7000 | 40 |