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: libmDot-Custom MTS-Serial
Fork of mDot_AT_firmware_CUSTOM by
To change channel plans replace AS923 with AU915, EU868, KR920 or US915 on line 15
#define CHANNEL_PLAN CP_AS923
CommandTerminal/CmdUplinkCounter.cpp@14:e80ace5a6834, 2016-08-29 (annotated)
- Committer:
- Jason Reiss
- Date:
- Mon Aug 29 10:05:41 2016 -0500
- Revision:
- 14:e80ace5a6834
- Parent:
- 9:ff62b20f7000
Update commands
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
9:ff62b20f7000 | 1 | #include "CmdUplinkCounter.h" |
Mike Fiore |
9:ff62b20f7000 | 2 | |
Jason Reiss |
14:e80ace5a6834 | 3 | CmdUplinkCounter::CmdUplinkCounter() |
Jason Reiss |
14:e80ace5a6834 | 4 | : Command("Uplink Counter", "AT+ULC", "Get or set the uplink counter for the next packet", "(0-4294967295)") |
Jason Reiss |
14:e80ace5a6834 | 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 CmdUplinkCounter::action(std::vector<std::string> args) { |
Mike Fiore |
9:ff62b20f7000 | 10 | if (args.size() == 1) { |
Jason Reiss |
14:e80ace5a6834 | 11 | CommandTerminal::Serial()->writef("%u\r\n", CommandTerminal::Dot()->getUpLinkCounter()); |
Mike Fiore |
9:ff62b20f7000 | 12 | } else if (args.size() == 2) { |
Jason Reiss |
14:e80ace5a6834 | 13 | |
Mike Fiore |
9:ff62b20f7000 | 14 | int count; |
Mike Fiore |
9:ff62b20f7000 | 15 | sscanf(args[1].c_str(), "%d", &count); |
Mike Fiore |
9:ff62b20f7000 | 16 | |
Jason Reiss |
14:e80ace5a6834 | 17 | if (CommandTerminal::Dot()->setUpLinkCounter(count) != mDot::MDOT_OK) { |
Jason Reiss |
14:e80ace5a6834 | 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 CmdUplinkCounter::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 | int count; |
Mike Fiore |
9:ff62b20f7000 | 32 | if (sscanf(args[1].c_str(), "%d", &count) == 1) { |
Mike Fiore |
9:ff62b20f7000 | 33 | if (count > 4294967295) { |
Jason Reiss |
14:e80ace5a6834 | 34 | CommandTerminal::setErrorMessage("Invalid uplink counter, expects (0-4294967295)"); |
Mike Fiore |
9:ff62b20f7000 | 35 | return false; |
Mike Fiore |
9:ff62b20f7000 | 36 | } |
Mike Fiore |
9:ff62b20f7000 | 37 | return true; |
Mike Fiore |
9:ff62b20f7000 | 38 | } |
Mike Fiore |
9:ff62b20f7000 | 39 | } |
Mike Fiore |
9:ff62b20f7000 | 40 | |
Jason Reiss |
14:e80ace5a6834 | 41 | CommandTerminal::setErrorMessage("Invalid arguments"); |
Mike Fiore |
9:ff62b20f7000 | 42 | return false; |
Mike Fiore |
9:ff62b20f7000 | 43 | } |
Mike Fiore |
9:ff62b20f7000 | 44 |