AT command firmware for MultiTech Dot devices.

Fork of mDot_AT_firmware by MultiTech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CmdUplinkCounter.cpp Source File

CmdUplinkCounter.cpp

00001 #include "CmdUplinkCounter.h"
00002 
00003 CmdUplinkCounter::CmdUplinkCounter() :
00004 #if MTS_CMD_TERM_VERBOSE
00005     Command("Uplink Counter", "AT+ULC", "Get or set the uplink counter for the next packet", "(0-4294967295)")
00006 #else
00007     Command("AT+ULC")
00008 #endif
00009 {
00010     _queryable = true;
00011 }
00012 
00013 uint32_t CmdUplinkCounter::action(const std::vector<std::string>& args) {
00014     if (args.size() == 1) {
00015         CommandTerminal::Serial()->writef("%" SCNu32 "\r\n", CommandTerminal::Dot()->getUpLinkCounter());
00016     } else if (args.size() == 2) {
00017 
00018         uint32_t count;
00019         sscanf(args[1].c_str(), "%" SCNu32, &count);
00020 
00021         if (CommandTerminal::Dot()->setUpLinkCounter(count) != mDot::MDOT_OK) {
00022             return 1;
00023         }
00024     }
00025     return 0;
00026 }
00027 
00028 bool CmdUplinkCounter::verify(const std::vector<std::string>& args) {
00029     if (args.size() == 1)
00030         return true;
00031 
00032     if (args.size() == 2) {
00033 
00034         uint32_t count;
00035         if (sscanf(args[1].c_str(), "%" SCNu32, &count) == 1) {
00036             if (count > 4294967295U) {
00037 #if MTS_CMD_TERM_VERBOSE
00038                 CommandTerminal::setErrorMessage("Invalid uplink counter, expects (0-4294967295)");
00039 #endif
00040                 return false;
00041             }
00042             return true;
00043         }
00044     }
00045 
00046 #if MTS_CMD_TERM_VERBOSE
00047     CommandTerminal::setErrorMessage("Invalid arguments");
00048 #endif
00049     return false;
00050 }
00051